使用 DirectoryCatalog 时动态更改部件 (DLL)

发布于 2024-10-06 08:10:20 字数 283 浏览 1 评论 0原文

使用 MEF,在将新插件(包含 partsDLLs)添加到插件文件夹后,调用 DirectoryCatalog 上的刷新将更新容器(如果允许重组)并且新添加的插件变得可访问。

我的问题是,如果我们需要动态替换DLLpart)怎么办?

我尝试了此操作,但所有加载的部件都被MEF锁定(写保护)并且无法替换。

Using MEF, after adding new plugins (DLLs containing parts) to plugins folder, calling a refresh on DirectoryCatalog would update container (if recomposition is allowed) and new added plugins become accessible.

My question is what if we need to replace a DLL (part) dynamically ?

I tried this but all loaded parts are locked (write-protected) by MEF and cannot be replaced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑叹一世浮沉 2024-10-13 08:10:20

.NET 锁定了您的 DLL。您无法从 AppDomain 卸载程序集,并且在加载它们时通常会有一个锁。您可以为 AppDomain 启用卷影复制,以便删除 DLL。它们仍然会被加载,但当您调用“刷新”并将它们从目录中删除时,DirectoryCatalog 会发现它们已经消失。

It's .NET that has a lock on your DLLs. You can't unload assemblies from an AppDomain, and while they are loaded there will normally be a lock. You can enable shadow copying for the AppDomain to let you delete the DLLs. They would still be loaded but the DirectoryCatalog would see they were gone when you called Refresh and remove them from the catalog.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文