Question

So i have some code, that run plugin (plugin compiled with include to references of main assembly) This is a server objects.

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);
        }
    }

In my plugin i`l try to do some like that

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
    }
}

Any ideas where can be my problem?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top