SetData, GetData : AppDomain « Development Class « C# / C Sharp






SetData, GetData

 

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.Configure the AppDomainSetup
3.SetPrincipalPolicy
4.FriendlyName
5.creates three instances of the same type. A local and two remote proxies to object instances are constructed:
6.OnUnhandledException method is added to the AppDomain.UnhandledException event