我需要在我的应用程序中使用跨应用程序域调用,有时我会遇到此 RemotingException:
Object '/2fa53226_da41_42ba_b185_ec7d9c454712/ygiw+xfegmkhdinj7g2kpkhc_7.rem' has been disconnected or does not exist at the server.
目标对象还活着,我查过了。
UPD 我在目标对象的终结器中设置了断点,但它从未命中。因此,这个对象是事件的并且没有被 GC。
最佳答案
那可能是因为服务器端的本地垃圾收集器收集了对象。您可以通过续租来防止这种情况发生。您可以在这些文章中阅读更多相关信息:
- Managing the Lifetime of Remote .NET Objects with Leasing and Sponsorship
- CLR Inside Out: Managing Object Lifetime
更新:不幸的是,2008 年或更早的 MSDN 杂志不再可以在线浏览,只能以 .chm 文件的形式下载到本地计算机。以前的问题可以在以下位置找到:
- 通过租赁和赞助管理远程 .NET 对象的生命周期 December 2003 issue
- CLR Inside Out:在 November 2007 issue 中管理对象生命周期
关于c# - "Object has been disconnected or does not exist at the server"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6339469/