AppDomain.SetData : AppDomain « System « C# / C Sharp by API






AppDomain.SetData

 

using System; 
using System.Reflection;
using System.Collections;

class ListModifier{
    public ListModifier()
    {
        ArrayList list = (ArrayList)AppDomain.CurrentDomain.GetData("Pets");
        list.Add("turtle");
    }
}
class MainClass{
      public static void Main(){
          AppDomain domain = AppDomain.CreateDomain("Test");

          ArrayList list = new ArrayList();
          list.Add("dog");
          list.Add("cat");
          list.Add("fish");

          domain.SetData("Pets", list);

          domain.CreateInstance("MainClass","Apress.VisualCSharpRecipes.Chapter03.ListModifier");

          foreach (string s in (ArrayList)domain.GetData("Pets")) {
              Console.WriteLine(s);
          }
      }
}

   
  








Related examples in the same category

1.AppDomain.CreateDomain
2.AppDomain.CreateInstance
3.AppDomain.CreateInstanceAndUnwrap
4.AppDomain.CreateInstanceFromAndUnwrap
5.AppDomain.CurrentDomain.FriendlyName
6.AppDomain.CurrentDomain
7.AppDomain.DefineDynamicAssembly
8.AppDomain.DoCallBack
9.AppDomain.DomainUnload
10.AppDomain.FriendlyName
11.AppDomain.GetAssemblies
12.AppDomain.GetData
13.AppDomain.OnUnhandledException
14.AppDomain.ProcessExit
15.AppDomain.SetPrincipalPolicy
16.AppDomain.Unload