获取对象的应用程序域应用程序、对象

由网友(長得太帥忚四㈠種檌)分享简介:有没有什么办法,以确定其中的AppDomain是创建一个对象或对象句柄实例?Is there any way to determine in which AppDomain was an object or ObjectHandle instance created?推荐答案从另一个应用程序域中的对象是透明代理。...

有没有什么办法,以确定其中的AppDomain是创建一个对象或对象句柄实例?

Is there any way to determine in which AppDomain was an object or ObjectHandle instance created?

推荐答案

从另一个应用程序域中的对象是透明代理。有可能得到真正的代理服务器和访问私有字段包含域ID:

An object from another app domain is a transparent proxy. It is possible to get the real proxy and access the private field that contains the domain id:

public static int GetObjectAppDomain(object proxy)
{
    RealProxy rp = RemotingServices.GetRealProxy(proxy);
    int id = (int)rp.GetType().GetField("_domainID", BindingFlags.Instance|BindingFlags.NonPublic).GetValue(rp);
    return id;
}

如果不知道可能的应用程序域的列表,这里 是一种方法,让所有应用程序域的列表中。

If the list of possible app domains isn't known, here is a way to get the list of all app domains.

阅读全文

相关推荐

最新文章