[英]Find the appdomain for a MarshalByRef object
I have a marshalled object which originated in another app domain. 我有一个源自另一个应用程序域的编组对象。
Is there a way to get a reference to the app domain where the object was created from the object itself? 是否有办法从对象本身获取对创建对象的应用程序域的引用?
//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);
Check out this answer of How to Get an AppDomain from an object 查看有关如何从对象获取AppDomain的答案
One possibility would be to create a property on your remote object. 一种可能性是在远程对象上创建一个属性。 The remote object could then call AppDomain.CurrentDomain
to get the remote AppDomain. 然后,远程对象可以调用AppDomain.CurrentDomain
来获取远程AppDomain。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.