AppDomain中和MarshalByRefObject的使用寿命:如何避免RemotingException? [英] AppDomain and MarshalByRefObject life time : how to avoid RemotingException?
问题描述
在MarshalByRef对象从传递一个AppDomain(1)到另一个(2),如果你在第二的AppDomain(2)你会得到一个RemotingException调用一个方法就可以了之前等待6分钟:
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 RemotingException :
System.Runtime.Remoting.RemotingException:
对象[...]已断开或
不在服务器存在。
System.Runtime.Remoting.RemotingException: Object [...] has been disconnected or does not exist at the server.
这个ISSE有些文档:
Some documentation about this isse :
- 的http://博客.microsoft.co.il /博客/武/存档/ 2008/07/19 /应用程序域和 - 远程 - 生命时间service.aspx
- 的 http://blogs.msdn.com/cbrumme/archive/2003/06/01/51466.aspx - 实例终身,cbrumme说,我们的应的解决这个问题。 :(
- http://blogs.microsoft.co.il/blogs/sasha/archive/2008/07/19/appdomains-and-remoting-life-time-service.aspx
- http://blogs.msdn.com/cbrumme/archive/2003/06/01/51466.aspx - Instance Lifetime, cbrumme says "We should fix this." :(
纠正我,如果我错了:如果InitializeLifetimeService返回null,对象只能在AppDomain中收集到1时的AppDomain 2卸载,即使收集代理?
Correct me if I'm wrong : if InitializeLifetimeService returns null, the object can only be collected in AppDomain 1 when AppDomain 2 is Unloaded, even if the proxy was collected ?
有没有一种方法来禁用的续航时间,并保持代理(在AppDomain中2)和对象(AppDomain1)活着?直到代理敲定也许有那么iSponsor ...
Is there a way to disable life time and keep the proxy (in AppDomain 2) and the object (in AppDomain1) alive until the proxy is Finalized ? Maybe with ISponsor... ?
推荐答案
请参阅这里回答:
这基本上说
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)]
public override object InitializeLifetimeService()
{
return null;
}
这篇关于AppDomain中和MarshalByRefObject的使用寿命:如何避免RemotingException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!