大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
public class AppDomainTest : MarshalByRefObject
{
public string TestMethodStr(string srcAppDomain)
{
string TTT = "TTT";
byte[] m_ExtraMemory = new byte[1024 * 1024 * 99];
Console.WriteLine(
"Code from the '{0}' AppDomain
" +
"called into the '{1}'. AppDomain.",
srcAppDomain, Thread.GetDomain().FriendlyName);
Console.WriteLine(
"Code from the TTT= '{0}' AppDomain
" +
"called into the '{1}'. AppDomain.",
TTT, Thread.GetDomain().FriendlyName);
return TTT;
}
}
static void Main(string[] args)AppDomain domainArcher = AppDomain.CreateDomain("MyNewDomain", null, null);
AppDomainTest test1 = (AppDomainTest)domainArcher.CreateInstanceAndUnwrap(System.Reflection.Assembly.GetCallingAssembly().FullName, "ConsoleApp1.AppDomainTest");
var tt1 = test1.TestMethodStr(Thread.GetDomain().FriendlyName);
Console.ReadLine();
}
进程内 AppDomain 间通信,但实测下,效率太慢了,只适合某些特殊情况下使用