简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM