using System; using System.ComponentModel; using System.Runtime.Remoting; namespace Test { public class Test { static void Main () { AppDomain domain = AppDomain.CreateDomain ("new-domain"); domain.DoCallBack (Run); Type stType = typeof (Something); Other st = (Other) domain.CreateInstanceAndUnwrap (stType.Assembly.FullName, stType.FullName); Console.WriteLine ("in main int: {0}", st.getInt ()); Console.WriteLine ("in main types: {0}", st.getTypeNames ()); } public static void Run () { DoRun(new Something ()); } public static void DoRun (Other some) { Console.WriteLine ("domain: {0}", AppDomain.CurrentDomain.FriendlyName); Console.WriteLine ("This is null: {0}", some.Mappings == null); Console.WriteLine ("int: {0}", some.getInt ()); } } public class Other : MarshalByRefObject { public T2 Mappings { get { return default(T2); } } public virtual int getInt () { return 123; } public virtual string getTypeNames () { return "error"; } } public class Something : Other { public override int getInt () { return 456; } public override string getTypeNames () { Console.WriteLine ("getTypeNames in {0}", AppDomain.CurrentDomain.FriendlyName); return typeof(T1).ToString () + " " + typeof(T2).ToString () + " " + typeof (T3).ToString (); } } }