您的位置:首页 > 编程语言 > ASP

System.Runtime.Remoting.RemotingException: has been disconnected or does not exist at the server

2017-03-28 16:36 447 查看
转自:http://blog.csdn.net/zewixi/article/details/6427746

为实现策略dll的独立加载,使用了跨应用程序域(AppDomain)技术,这个问题必和AppDomain有关,而且能猜测,应该是和对象的生存期有关。经过一番搜寻,找到这篇文献:
http://blogs.microsoft.co.il/blogs/sasha/archive/2008/07/19/appdomains-and-remoting-life-time-service.aspx
 

由上述文献得知,错误是MarshalByRefObject派生类对象的生存期(这里应该是指不活动就销毁的时间间隔)默认为5分钟所致。URWPGSim2D的客户端和服务端加载独立的策略dll文件,用到了两个继承于MarshalByRefObject的类。一个是用于加载策略的工厂类StrategyInterfaceFactory,一个是策略类Strategy。在这两个类中重载(override)InitializeLifetimeService方法,让其返回null而非一个ILease实现,即可让这两个类的对象生存期无限。
/// </summary>
/// override the InitializeLifetimeService to return null instead of a valid ILease implementation
/// to ensure this type of remote object never dies
/// </summary>
/// <returns>null</returns>
public override object InitializeLifetimeService()
{
//return base.InitializeLifetimeService();
return null; // makes the object live indefinitely
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  asp.net
相关文章推荐