所以我有一些代码,运行插件(使用include编译的插件到主程序集的引用) 这是一个服务器对象。
using System;
using System.Runtime.Remoting.Lifetime;
namespace RemoteType
{
public class TestClass : System.MarshalByRefObject
{
public string name;
public TestClass(string n)
{
name = n;
}
}
public class MyRemoteObject : System.MarshalByRefObject
{
public string X = "Test3";
public override object InitializeLifetimeService()
{
return null;
}
public void Test2()
{
Console.WriteLine("Second Test");
}
public void Test3()
{
Console.WriteLine(X);
}
public void Test(TestClass class)
{
Console.WriteLine(class.name);
}
}
在我的插件中,我会尝试做那样的事情
namespace Plugin
{
public class Plugin : System.MarshalByRefObject
{
public MyRemoteObject remObject; //initialized on server via remObject.SetValue
//So now i can use this object, and all will be ok
remObject.Test2();
remObject.Test3();
//BUT if i`m try to do this
TestClass x = new TestClass("First Test");
remObject.Test(x); //!! When server object try to access x.name i`l get exception that current domain unloaded
}
}
任何想法都可能是我的问题?