问题
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