473,327 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

get AppDomains collection from a process.

153 100+
I was wondering how to get a collection of all the AddDomains in the process.
Like Process.GetCurrentProcess().GetAppDomains();

Any clues to get that ?

All i wanna do is enumerate all the appdomains in a specific process.
Oct 14 '08 #1
1 1798
PRR
750 Expert 512MB
I was wondering how to get a collection of all the AddDomains in the process.
Like Process.GetCurrentProcess().GetAppDomains();

Any clues to get that ?

All i wanna do is enumerate all the appdomains in a specific process.
Have a look at this
Thomas Scheidegger
Jamie Cansdale

For the below code to work add reference to WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscoree .tlb

Expand|Select|Wrap|Line Numbers
  1. public void GetApp()
  2.         {
  3.             AppDomain one =  AppDomain.CreateDomain("One");
  4.             AppDomain two =  AppDomain.CreateDomain("Two");
  5.  
  6.             CorRuntimeHostClass host = new CorRuntimeHostClass();
  7.  
  8.             try
  9.             {
  10.  
  11.                 ArrayList list = new ArrayList();
  12.                 IntPtr enumHandle;
  13.  
  14.                 host.EnumDomains(out enumHandle);
  15.  
  16.                 while (true)
  17.                 {
  18.  
  19.                     object domain;
  20.  
  21.                     host.NextDomain(enumHandle, out domain);
  22.  
  23.                     if (domain == null) break;
  24.  
  25.                     list.Add((AppDomain)domain);
  26.  
  27.                 }
  28.  
  29.                 host.CloseEnum(enumHandle);
  30.  
  31.                 foreach (object o in list)
  32.                 {
  33.                     AppDomain aa = o as AppDomain;
  34.                     Console.WriteLine(aa.FriendlyName);
  35.                 }
  36.  
  37.             }
  38.  
  39.             finally
  40.             {
  41.  
  42.                 Marshal.ReleaseComObject(host);
  43.                 //AppDomain aa in                
  44.  
  45.             }
  46.  
  47.         }//
  48.  
i hope theres a easier way of doin this... maybe you should look into WMI classes... I havent found a simple way of doin it ...like u said ..Process.GetCurrentProcess().GetAppDomains()...
i may have completely missed something simpler....
hope this helps.. let me know if you find a simpler way ...
Oct 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Daylor | last post by:
hi. i have mult thread vb.net application. it has 30 threads. each thread serves 1 phone caller. the question : is there a reason , to create appdomain for each Phone Service ? meaning 30...
4
by: Mountain Bikn' Guy | last post by:
I need some advice on this. I am working on a fairly complex calculator app (C#) with lots of functions (and these functions in turn use math functions from an unmanaged C DLL). A calculation takes...
1
by: billr | last post by:
hi there, I hope that someone will be able to shed some light on little old confused me. We are developing an application which will be deployed onto a Terminal Server machine. The application...
6
by: Stephen Walch | last post by:
Our application environment consists of three basic layers: 1. Third-party unmanaged DLLs that were written before the CLR was invented and maintain a significant amount of information (including...
4
by: Laser Lu | last post by:
Hi, can anybody tell me if it is possible to detect whether a process has some AppDomain(s) hosted, and how to get the list of all the hosted AppDomains within that process?
0
by: kayakyakr | last post by:
I'm working with a set of experiments in a large system that is using AppDomains for isolation and wants to make a call out to an umanaged dll. The test dll has two methods, SetNumber(int num) and...
3
by: | last post by:
If this is simple, forgive my ignorance, but I'm coming from the CompactFramework where we don't use AppDomains. I did a fair bit of archive searching and couldn't find an answer and I got no...
0
by: jeremyje | last post by:
I would like to create an application where I have many concurrent processes being managed by a monitoring process. Each process that is "managed" will be invoked from an assembly dll (think...
0
by: PRR | last post by:
Here is a code i found on "how to enumerate appdomains in a current process". The original code was posted by Thomas Scheidegger Add the following as a COM reference -...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.