AppDomain and MarshalByRefObject life time : how to avoid RemotingException?

后端 未结 10 2003
时光取名叫无心
时光取名叫无心 2020-12-04 08:53

When a MarshalByRef object is passed from an AppDomain (1) to another (2), if you wait 6 mins before calling a method on it in the second AppDomain (2) you will get a Remoti

10条回答
  •  攒了一身酷
    2020-12-04 09:06

    I created a class which disconnect on destruction.

    public class MarshalByRefObjectPermanent : MarshalByRefObject
    {
        public override object InitializeLifetimeService()
        {
            return null;
        }
    
        ~MarshalByRefObjectPermanent()
        {
            RemotingServices.Disconnect(this);
        }
    }
    

提交回复
热议问题