在 AppDomain 之间共享类型
我目前正在为我正在编写的程序开发一个加载项系统,并且遇到了主机和加载项应如何在公共基础上进行通信的问题。我使用 System.AddIn 命名空间(以前称为 MAF)来发现、隔离和激活加载项。
现在,由于我希望(需要?)加载项存在于与主机不同的 AppDomain 中,因此存在类型无法在 AppDomain 之间共享的问题,因此不能在主机和加载项之间共享。我知道 AppDomain 之间有一些内置的类型编组支持,但对此一无所知,也不知道它是否合适。
所以问题是,如果我想在两个单独的应用程序域中的加载项和主机之间共享相同的对象(实例),我该怎么办?也许有更微妙的方法来解决这个问题?
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.
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. I understand there is some built-in support for type marshalling between AppDomains, but know nothing about this, nor whether it is even appropriate.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以看起来
MarshalByRefObject
和AppDomain 对象上的几个函数为我想要的提供了基础。我想案件暂时结束了。So it seems
MarshalByRefObject
and a few functions on the AppDomain object provides the basis for exactly what I want. Case closed for now, I think.