Restart ASP.NET application when folder contents change

放肆的年华 提交于 2019-12-19 10:27:11

问题


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?


回答1:


IF the plugins directory is under your Bin directory, the web app will automatically be restarted when anything changes.




回答2:


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.



来源:https://stackoverflow.com/questions/330390/restart-asp-net-application-when-folder-contents-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!