简体   繁体   English

如何将实例传递给另一个appdomain?

[英]How to pass an instance to another appdomain?

I need to pass an instance to (not from) an AppDomain. 我需要将实例传递给(而不是来自)AppDomain。 I've seen a lot of info about how to do the reverse (call create on a domain and use the object locally), but what i want is to pass an instance i already have (not one i create from the domain object), this instance is a MarshalByRefObject and i want to pass it to another domain from my main domain. 我已经看到了很多有关如何进行反向操作的信息(在域上调用create并在本地使用该对象),但是我想要传递的是我已经拥有的一个实例(不是我通过该域对象创建的),这个实例是MarshalByRefObject,我想将其从主域传递到另一个域。 Is this possible at all? 这有可能吗?

   var MyObject = GetAlreadyPopulatedObject();
   AnotherDomain.MakeObjectVisible(MyObject); // this is what i'm trying to do, make the instance i have available somewhere else
   // And if it's possible, how would i access it from the other Domain? How can i find it?

The scenario i have is i'm handling data that i create, i want to pass it for manipulation to a plugin in another appdomain, and then to retrieve the modified version and i'm a bit at a loss. 我遇到的情况是,我正在处理自己创建的数据,我想将其传递给另一个appdomain中的插件,然后检索修改后的版本,这让我有些茫然。

最后,我找到了一个替代方法(domain.SetData / domain.GetData)来跨域边界传递对象,我不确定这样做是否最干净/最容易/最快/建议这样做,所以除非将自己标记为答案,否则一段时间后,我没有其他答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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