There will be a lot of situations where you need to recycle only one Application Domain inside an Application Pool. One good way to do this is to just edit the web.config for that particular application which will force the App Domain to recycle. I was thinking to do in a programmatic way – that too as an extension to my IIS7 UI module I wrote earlier. This is how it looks now:
Microsoft.Web.Administration namespace has a lot of classes – ServerManager, WorkerProcess, ApplicationDomain, etc.
I get the list of Workerprocesses from the ServerManager.WorkerProcesses collection. From the collection, I get individual WorkerProcess. There is an ApplicationDomains collection in each WorkerProcess. You have a method Unload in the ApplicationDomain class. Below is the piece of code which does the Unload:
WPname = comboBox2.SelectedItem.ToString();
WPname = WPname.Substring(0,WPname.IndexOf(‘_’));
And, I get ApplicationDomain.Id, Idle, VirtualPath, PhysicalPath and display them in a groupbox.
I’ve attached the new FrebUI.DLL on this post. Feel free to download and use, but use @ your own risk. Feel free to write to me in case you have any doubts on this.