AppDomain中和MarshalByRefObject的使用寿命:如何避免RemotingException? [英] AppDomain and MarshalByRefObject life time : how to avoid RemotingException?

查看:216
本文介绍了AppDomain中和MarshalByRefObject的使用寿命:如何避免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://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... ?

推荐答案

请参阅这里回答:

的http:// social.msdn.microsoft.com/Forums/en-US/netfxremoting/thread/3ab17b40-546f-4373-8c08-f0f072d818c9/

这基本上说

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)]
public override object InitializeLifetimeService()
{
  return null;
}

这篇关于AppDomain中和MarshalByRefObject的使用寿命:如何避免RemotingException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆