使插件文件夹在 ASP.NET 中可写

发布于 2024-11-15 04:48:10 字数 229 浏览 7 评论 0原文

我在基于插件的 ASP.NET 应用程序中使用 MEF。将文件系统观察器Container.Refresh()连接起来,任何新插件都会在复制到插件文件夹后自动加载。

问题是当我想删除或替换已加载的插件时。它被w3wp锁定,无法删除。我读过有关Shadow Copy的内容,但找不到好的示例或文章。

I'm using MEF in a plugin based ASP.NET application. Wiring up a File System Watcher with Container.Refresh() any new plugin is loaded automatically upon being copied to the plugin folder.

The problem is when I want to delete or replace a loaded plugin. It is locked by w3wp and cannot be deleted. I read about Shadow Copy but cannot find a good example or article.

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

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

发布评论

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

评论(2

薯片软お妹 2024-11-22 04:48:10

尝试将插件文件夹添加到 AppDomainSetup.ShadowCopyDirectories。此属性是一个以分号分隔的目录列表,其中包含应通过卷影副本加载的程序集。

通常,您还需要将 AppDomainSetup.ShadowCopyFiles 设置为 < code>"true" 但我认为这已经是 ASP.NET 应用程序域的默认设置。

但是,请注意,加载新版本的插件不会神奇地卸载旧版本。唯一的方法是卸载包含它的 AppDomain。由于这需要您在单独的应用程序域中加载插件,因此这可能会带来更多麻烦。

停止服务、更新 DLL,然后重新启动可能更简单、更安全、更有效。

Try adding the plugin folder to AppDomainSetup.ShadowCopyDirectories. This property is a semicolon-seperated list of directories containing assemblies that should be loaded via shadow copies.

Normally you also need to set AppDomainSetup.ShadowCopyFiles to "true" but I think this is already the default for ASP.NET appdomains.

However, be aware that loading a new version of a plugin will not magically unload the old version. The only way to do that is to unload the AppDomain containing it. Since this requires you to load plugins in a separate appdomain, this is probably more trouble than it is worth.

It is probably simpler, safer and more effective to just stop the service, update the DLLs, and restart.

百思不得你姐 2024-11-22 04:48:10

确保正确清理所有非托管资源。听起来您可能已经打开了一个文件流,但没有正确关闭/处置它,这可能会通过首先使用该文件的进程锁定该文件。有关 using 语句的更多信息:http://www.blackwasp.co .uk/UsingStatement.aspx

Make sure you are cleaning up all your unmanaged resources properly. It sounds like you may have opened a file stream but didn't properly close/dispose of it, and this may lock up a file by the process that was working with it in the first place. More info on using statement here: http://www.blackwasp.co.uk/UsingStatement.aspx

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