【问题标题】:Find the appdomain for a MarshalByRef object查找 MarshalByRef 对象的 appdomain
【发布时间】:2014-09-03 23:45:53
【问题描述】:

我有一个源自另一个应用程序域的编组对象。

有没有办法从对象本身获取对创建对象的应用程序域的引用?

//i dont have a ref to this anymore.
AppDomain ad = AppDomain.CreateDomain("MyDomain");
MyRemoteObject r = (MyRemoteObject)ad.CreateInstanceFromAndUnwrap("MyCode.dll", "MyRemoteObject");

//is there a something such that i can re-discover the app domain
var appDomain = Something(r);

【问题讨论】:

    标签: c# appdomain


    【解决方案1】:

    查看How to Get an AppDomain from an object的这个答案

    一种可能性是在您的远程对象上创建一个属性。然后远程对象可以调用AppDomain.CurrentDomain 来获取远程AppDomain。

    【讨论】:

    • 我看过那篇文章,但答案实际上是在谈论序列化对象而不是编组对象。不幸的是,我不控制应用程序域另一端的对象,所以我真的不能在远程域中执行AppDomain.CurrentDomain
    • @IllidanS4 它看起来没有更新,它仍然需要远程对象的操作。
    猜你喜欢
    • 2012-06-03
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多