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实现,即可让这两个类的对象生存期无限。
为实现策略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 }
相关文章推荐
- System.Runtime.InteropServices.COMException The Product License has not been initialized. ESRI GeoDatabase
- 奇葩问题:This file could not be checked in because the original version of the file on the server was moved or deleted. A new version of this file has been saved to the server, but your check-in comments were not saved
- System.Runtime.InteropServices.COMException(0x8004020F): The server rejected one or more recipient addresses.
- Potential causes of the "SQL Server does not exist or access denied" error message
- The Windows account sa does not exist and cannot be provisioned as a SQL Server system administrator
- [TroubleShooting] The server network address can not be reached or does not exist
- RPC Fault faultString="[MessagingError message='Destination 'data-push' either does not exist or the destination has no channels
- CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System.Data'
- the server has disconnected with an error. server message reads: a protocol error occurred.chang of username or service not allowedroot, (root,ssh-con
- Unity3d——报错 The type or namespace name `Ports' does not exist in the namespace `System.IO'
- System.Security.Cryptography.CryptographicException: Keyset does not exist or Access is denied.
- The type or namespace name 'Windows' does not exist in the class or namespace 'System'
- [TroubleShooting] The server network address can not be reached or does not exist
- About Derby "ERROR 42X51: The class '***' does not exist or is inaccessible. This can hap pen if the class is not public."
- 解决错误“Logon Failure: The User Has Not Been Granted The Requested Logon Type At This Computer”
- java.lang.UnsatisfiedLinkError,(A file or directory in the path name does not exist.
- Variable 'X' is used before it has been assigned a value. A null reference exception could result at runtime.
- System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException: Operation is not valid due to the current state of the obj
- The plugin 'org.apache.maven.plugins:maven-eclipse-plugin' does not exist or no valid version could be found 解决
- 'ddlXXX' has a SelectedIndex which is invalid because it does not exist in the list of items