且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取对象的应用程序域

更新时间:2023-11-22 21:09:34

从另一个应用程序域中的对象是透明代理。有可能得到真正的代理服务器和访问私有字段包含域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.