简体   繁体   English

在AppDomain之间共享类型

[英]Sharing Types between AppDomains

I am currently developing an add-in system for a program I am writing, and have run into the issue of how the host and add-in should communicate on a common base. 我目前正在为我正在编写的程序开发一个加载项系统,并且遇到了主机和加载项应如何在同一基础上进行通信的问题。 I use the System.AddIn namespace (previously called the MAF) for discovery, isolation, and activation of add-ins. 我使用System.AddIn命名空间(以前称为MAF)来发现,隔离和激活加载项。

Now, since I want (need?) add-ins to exist in separate AppDomains from the host, there exists the problem that types cannot be shared between AppDomains and thus not between host and add-in. 现在,由于我希望(需要?)加载项与主机存在于单独的AppDomain中,因此存在一个问题,即无法在AppDomain之间共享类型,因此不能在主机与加载项之间共享类型。 I understand there is some built-in support for type marshalling between AppDomains, but know nothing about this, nor whether it is even appropriate. 我知道AppDomain之间存在一些对类型编组的内置支持,但是对此一无所知,甚至都不知道。

So the question is, what can I do if I want to share the same object (instance) between add-in and host in two separate app-domains? 所以问题是,如果要在两个单独的应用程序域中的加载项和主机之间共享同一对象(实例),该怎么办? Perhaps there is a more subtle way around this problem? 也许有解决这个问题的更巧妙的方法?

So it seems MarshalByRefObject and a few functions on the AppDomain object provides the basis for exactly what I want. 因此,似乎MarshalByRefObject和AppDomain对象上的一些函数为我想要的提供了基础。 Case closed for now, I think. 我认为案件已经结案。

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

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