views:

178

answers:

3

I have a service app that creates AppDomain's during the course of its use for long running tasks. I've been tracking these by storing them in a Hashtable with a unique ID.

After a task is completed the service app then unloads the AppDomain allocated to that task and then it's removed it from the appdomain Hashtable.

Purely from a sanity checking point of view, is there a way I can query the CLR to see what app domains are still loaded by the creating app domain (i.e. so I can compare the tracking Hashtable against what the CLR actually sees)?

Thanks in advance.
Kev

+2  A: 

AFAIK, you need to keep your own list - like you are already.

Marc Gravell
Yep...after a couple of months of off and on research. This does seem to be the way.
Kev
+1  A: 

If you use the unmanaged APIs you may set-up a DomainManager that gets called on each AppDomain creation, and you'll find that many pieces are creating their own AppDomains, e.g. WCF. A detailed explanatin is in Customizing the Microsoft .NET Framework Common Language Runtime

Another route is using the debug APIs.

Giulio Vian
Giulio - thanks for the answer and thanks for the link to the book. Can't believe I missed that one, looks fascinating.
Kev
+2  A: 

I think you would like to check also this article - "Working with Application Domains in WPF". Simply format the link (replace the pipes by slashes), because I cannot post it as an anonymous :-)

www.infosysblogs.com|microsoft|2008|10|working_with_application_domai_1.html

+1 .. http://www.infosysblogs.com/microsoft/2008/10/working_with_application_domai_1.html looks like a very comprehensive article!
Rob
+1 too....thanks for that.
Kev