111,129
社区成员
发帖
与我相关
我的任务
分享
AppDomain child = AppDomain.CreateDomain("ChildDomain");
child.SetData("PRIVATE_BINPATH", "myBin");
Console.WriteLine("创建非引用或传值对象");
ObjectHandle oh = (ObjectHandle)child.CreateInstanceFrom("C:\\aa\\demo.dll", "Demo.MyValueObj");
try
{
object obj = (object)oh.Unwrap();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
using System;
using System.Threading;
namespace Demo
{
[Serializable]
class MyValueObj
{
int i=0,j=0;
public MyValueObj()
{
Console.WriteLine("当前应用域名称为:{0}",AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine("当前线程的代码是:{0}",Thread.CurrentThread.GetHashCode().ToString());
}
public void DoSomeWork()
{
Console.WriteLine("我是Demo.MyValueObj对象");
Console.WriteLine("当前应用域名称为:{0}",AppDomain.CurrentDomain.FriendlyName);
Console.WriteLine("当前线程的代码是:{0}",Thread.CurrentThread.GetHashCode().ToString());
Console.WriteLine("i={0},j={1}",i,j);
}
}
}