The easiest way to do cross-update?

I need to call an object method in another appdomain (pass parameter and get the result). Ideas?

UPD both AppDomain are not created by my code (the host application creates it and then calls my code). How can I access one AppDomain from another?

+11
c # clr ipc
Jun 05 2018-11-11T00:
source share
2 answers

If you created an object in another domain, for example. with AppDomain.CreateInstanceAndUnwrap , all you need to call an object in another domain is call the object's method.

The easiest way to make a cross-domain call to a domain is to simply make a call directly to this object, which actually opens from another domain through its proxy server that exists in another domain.

UPD
Unfortunately, getting a host domain is not so simple. You should list the type domains and find the host file among them. I believe your host domain is the one for which the AppDomain.IsDefaultAppDomain method returns true.

+14
Jun 05 2018-11-11T00:
source share

This is usually achieved using AppDomain.DoCallBack . You must make sure that if you want to pass parameters, you need to create a serializable object, the method of which you pass to the method described above. In the callback method, you can execute another AppDomain callback to return the result to the original AppDomain.

+3
Jun 05 2018-11-11T00:
source share



All Articles