public static void Marshlling()
  {
   AppDomain adCallingThreadMain = Thread.GetDomain();
   Console.WriteLine("main thread run in {0}", adCallingThreadMain.FriendlyName);
   string exeAssembly = Assembly.GetEntryAssembly().FullName;
  
   Console.WriteLine("main assembly {0}", exeAssembly);

   AppDomain ad2 = AppDomain.CreateDomain("Demo 1", null, null);
   //返回对新的对象的引用
   MarshalByRefType mar = null;

//该句代码开始没加类的命名空间,就报出异常。加上了命名空间就Ok了
   mar = (MarshalByRefType)ad2.CreateInstanceAndUnwrap(exeAssembly, "ConsoleApplication9.MarshalByRefType");
   Console.WriteLine("Type {0}", mar.GetType());
   Console.WriteLine("Is proxy {0}", RemotingServices.IsTransparentProxy(mar));

   
  }

相关文章:

  • 2021-11-30
  • 2021-09-04
  • 2022-12-23
  • 2021-04-26
  • 2021-12-25
  • 2022-02-28
  • 2022-02-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
相关资源
相似解决方案