我应该如何跨应用程序域边界加载程序集来加载和卸载模块?
我知道在运行时动态加载程序集的限制会阻止其卸载。相反,有人建议,如果这是一个要求,我应该改为加载其他应用程序域中的模块,然后跨域边界执行代码。
我怎样才能简化这个开发过程并处理这个场景?有哪些工具或框架可用?
I'm aware of the limitations of loading an assembly dynamically during run-time that prevents it from being unloaded. Instead it's been suggested that, if this is a requirement, that I should instead load modules in other application domains and then execute code across the domain boundries.
How can I ease this development process and work with this scenario? What tools or frameworks are available?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MEF [1] 是否引导您走向正确的方向?或者你可以选择温莎城堡 [2],尽管我不需要卸载其中任何一个。
[1] http://code.msdn.microsoft.com/mef
[2] http://www.castleproject.org/container/index.html
Does MEF [1] send you in the right direction? Or you could go with Castle Windsor [2], though I've not had a need to unload with either.
[1] http://code.msdn.microsoft.com/mef
[2] http://www.castleproject.org/container/index.html
这取决于“主机”应用程序和动态加载的代码之间的交互有多复杂。如果它相当复杂,那么您可能需要采用完整的 System.AddIn 路线。如果您的交互相当简单,那么您可能应该编写自己的类来处理程序集的加载和卸载。我已经为各种较小的项目做过很多次了,所以如果有帮助的话我可以发布代码。
It depends on how complicated the interaction is between your "host" app and the dynamically loaded code. If it is fairly complicated then you may want to go the full System.AddIn route. If your interactions are fairly simple then you should probably just write your own classes to handle the loading and unloading of the assemblies. I've done this a number of times for various smaller projects so I can post code if that would be helpful.