views:

608

answers:

2

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?

+4  A: 

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

leppie
It works, it works!!!
Vilx-
Cool :) Now if only you could have it working off other directories.
leppie
+2  A: 

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.

annakata
Will HttpRuntime.UnloadAppDomain() actually start the app again on subsequent requests?
leppie
Yes, it will. Although THIS request will still get served with the old version. I'll see if I can couple it with the FileSystemWatcher.
Vilx-
Actually IIRC UnloadAppDomain will terminate the current request (not 100% though) but it does restart on the next request (100%)
annakata