最简单的,使跨AppDomain的调用方式是什么? [英] Simplest way to make cross-appdomain call?

查看:157
本文介绍了最简单的,使跨AppDomain的调用方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要调用对象的方法在另一个应用程序域(通过参数,并得到结果)。想法?

I need to call a method of object in another appdomain (pass param and get result). Ideas?

UPD两个AppDomain中的被我的code(主机应用程序创建它,然后我的code被调用)创建没有。我怎样才能获得一个AppDomain中从另一个?

UPD both AppDomain's are created not by my code (host app creates it, and then my code gets called). How I can get access to one AppDomain from another?

推荐答案

如果您创建另一个域,例如对象与 AppDomain.CreateInstanceAndUnwrap ,所有你需要调用另一个域中的对象是调用对象的方法。

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
不幸的是获得主机域不是那么容易。你应该列举如这以及其中找到主机一台。我假设你的主机域名是一个针对该方法 AppDomain.IsDefaultAppDomain 返回的真正的。

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.

这篇关于最简单的,使跨AppDomain的调用方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆