3

I am trying to get the AppDomain for all the .NET Framework processes running on my machine. Any advice on how to do that?

Jeff B
  • 8,572
  • 17
  • 61
  • 140
swetha
  • 31
  • 3

1 Answers1

1

Im not entirely clear on what you are trying to do, but if you want to enumerate all running AppDomains by attaching Visual Studio to a process, see this link: Jack Gudenkauf "Enumerating AppDomains"

In that same vein, if you want to do this AT RUNTIME (without Visual Studio) then you will probably need to include a managed debugger in your program which will allow you to 'attach' to another process. Take a look at the managed debugger example, this demonstrates a debugger, written in C#. It will then allow you to execute an 'extension' within the target application process, such as is done in Jack Gudenkauf's article. CLR Managed Debugger (mdbg) Sample

Adam
  • 4,159
  • 4
  • 32
  • 53
  • Hi Adam Yes i want to enumerate the AppDomains which are Currently running in the .Net Framework. Through VS C# i can fetch the all AppDomains which are running in the Single applciarion But not from all the applications working in .Net Framework. – swetha May 12 '11 at 05:38
  • I would suggest you try the approach I have mentioned, using the Managed Debugger source code. It will allow you to 'connect' to any .net process, and enumerate AppDomains. – Adam Jun 24 '11 at 03:44
  • Is there any good way to enumerate through processes to see which ones are .NET? That would make this answer even better ;) – Jeff B Sep 27 '12 at 21:19
  • @Jeff - Take a look at this post http://stackoverflow.com/questions/943453/number-of-clr-and-gc-instances-running-on-a-machine - Shafqat Ahmed's answer provides a code snippet which should help. You could also shell the 'clrver' utility as described in Daniel Fortunov's answer to this question: http://stackoverflow.com/questions/4336889/how-to-tell-what-version-of-the-net-clr-is-loaded-by-a-running-application-on-x FYI - your comment is slightly OT ('is the CLR loaded' is different to actually getting a reference to an AppDomain) - you should post it as a new question. – Adam Sep 28 '12 at 02:04
  • Right, I think we might have a misunderstanding. Your answer discusses attaching to a process to get the `AppDomain`. I just felt that a more complete answer would include how to find which processes you need to attach to (i.e. "CLR loaded). Then again, I might be misunderstanding the process entirely ;) – Jeff B Sep 29 '12 at 03:35