Пример #1
0
        private static void Marshalling()
        {
            Program.GetDomainInfo(AppDomain.CurrentDomain);
            Console.WriteLine();

            AppDomain domain = AppDomain.CreateDomain("Marshalling");

            Assembly asm = Assembly.GetExecutingAssembly();

            Console.WriteLine("MarshalByRef");
            MarshalByRef clByRef = (MarshalByRef)domain.CreateInstanceAndUnwrap(asm.FullName, "Domains.MarshalByRef");

            Console.WriteLine("Is Proxy - {0}", RemotingServices.IsTransparentProxy(clByRef));
            Console.WriteLine();

            Console.WriteLine("MarshalByVal");
            MarshalByVal clByVal = (MarshalByVal)domain.CreateInstanceAndUnwrap(asm.FullName, "Domains.MarshalByVal");// clByRef.GetClassByVal();

            Console.WriteLine("Is Proxy - {0}", RemotingServices.IsTransparentProxy(clByVal));
            clByVal.Print();
            Console.WriteLine();

            Console.WriteLine("NoMarshal:");
            try
            {
                NoMarshal noMarshal = clByRef.NoMarshal();
                Console.WriteLine("Is Proxy - {0}", RemotingServices.IsTransparentProxy(noMarshal));
                Console.WriteLine();
            }
            catch (System.Runtime.Serialization.SerializationException e)
            {
                Console.WriteLine("Exception: {0}", e.Message);
            }
        }
Пример #2
0
 public NoMarshal GetNoMarshal(NoMarshal n)
 {
     return(new NoMarshal());
 }