文件夹内容更改时重新启动 ASP.NET 应用程序
我正在编写一个带有“插件”的网络应用程序。 这些插件将是 .DLL 文件,它将通过预定义的接口和东西导出其功能。 所有 .DLL 文件都位于名为“Plugins”的文件夹中,ASP.NET 应用程序在启动时加载它们(通过使用 Assembly.LoadFrom)。
问题是,在开发时,这些插件会经常更改(所有功能都在插件中,网站本身只是一个骨架)。 因此,我需要一种在 .DLL 文件更改时自动重新启动应用程序的方法。
我怎么做?
I'm writing a web application that will have "plugins". The plugins will be .DLL files which will export their functionality through predefined interfaces 'n stuff. All the .DLL files are in a folder called "Plugins", and the ASP.NET application loads them all upon startup (by using Assembly.LoadFrom).
The problem is that when developing, these plugins will change fairly often (all the functionality is in the plugins, the website itself is just a skeleton). Thus, I need a way to automatically restart the application when the .DLL files change.
How do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果插件目录位于您的 Bin 目录下,则当发生任何更改时,Web 应用程序将自动重新启动。
IF the plugins directory is under your Bin directory, the web app will automatically be restarted when anything changes.
FileSystemWatcher 类是此类问题的通用解决方案问题,
HttpRuntime.UnloadAppDomain();
是重新启动应用程序的一种方法。 我认为需要更多的研究/解释:有很多可能的解决方案。编辑:探索路径。 很好的答案。
The FileSystemWatcher class is a general solution to these kind of problems, and
HttpRuntime.UnloadAppDomain();
is one way to restart your app. I think more research/explanation is required: there are many possible solutions.Edit: Probling Paths. Nice answer.