跨AppDomain通信-创新互联
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 间通信,但实测下,效率太慢了,只适合某些特殊情况下使用
新闻标题:跨AppDomain通信-创新互联
文章起源:http://scyanting.com/article/dgccpi.html