Simplest way to make cross-appdomain call?

只谈情不闲聊 提交于 2019-11-27 15:06:51
Centro

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

The simplest way to make a cross-application domain call is just to make a call directly on that object, which actually is exposed from another domain via its proxy, existing in another domain.

UPD
Unfortunately getting the host domain is not that easy. You should enumerate domains like this and find among them the host one. I suppose that your host domain is the one for which the method AppDomain.IsDefaultAppDomain returns true.

Oliver Hanappi

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!