Is it possible to enumerate AppDomains ?

413 views
Skip to first unread message

Rajasekar Shanmugam

unread,
May 7, 2002, 4:05:19 PM5/7/02
to
Hi,

Is it possible to enumerate the AppDomains currently executing and list the
loaded assemblies in each ?

Thanks for your time.


NETMaster

unread,
May 7, 2002, 5:29:40 AM5/7/02
to
to list all assemblies:

Assembly[] allAsm = AppDomain.CurrentDomain.GetAssemblies();
foreach( Assembly asm in allAsm )
{...}

AFAIK to enum all AppDoms, you have to use (unmanaged?) .NET Debug APIs /interfaces

--
NETMaster (Thomas Scheidegger)
http://www.cetus-links.org/oo_csharp.html

"Rajasekar Shanmugam" <s_raj...@yahoo.com> wrote in message news:OeAu0nZ9BHA.692@tkmsftngp04...

Rajasekar Shanmugam

unread,
May 7, 2002, 7:23:17 PM5/7/02
to

Thanks a lot.


"NETMaster" <spam.ne...@swissonline.ch> wrote in message
news:e1IV2ma9BHA.2636@tkmsftngp05...

NETMaster

unread,
May 8, 2002, 3:48:31 AM5/8/02
to

to use the unmanaged interface, add a project reference (or do TLBIMP)
C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\mscoree.tlb

and code like:

// ================================================================
static void EnumAppDomainsAndAssemblies()
{
mscoree.CorRuntimeHostClass host = new mscoree.CorRuntimeHostClass();
IntPtr enumHandle = IntPtr.Zero;
host.EnumDomains( out enumHandle );
object dom = null;
while(true) {
host.NextDomain( enumHandle, out dom );
if( dom == null )
break;
AppDomain ad = (AppDomain) dom;
dom = null;
Console.WriteLine( "AppDomain: {0}", ad.FriendlyName );
Assembly[] allAsm = ad.GetAssemblies();


foreach( Assembly asm in allAsm )

Console.WriteLine( "\t{0}", asm.FullName );
ad = null;
}

host.CloseEnum( enumHandle );
int refctr = Marshal.ReleaseComObject( host );
host = null;
}
// ================================================================

--
NETMaster (Thomas Scheidegger)
http://www.cetus-links.org/oo_csharp.html

"NETMaster" <spam.ne...@swissonline.ch> wrote in message news:e1IV2ma9BHA.2636@tkmsftngp05...

> to list all assemblies:
> Assembly[] allAsm = AppDomain.CurrentDomain.GetAssemblies();
> foreach( Assembly asm in allAsm )
> {...}
> AFAIK to enum all AppDoms, you have to use (unmanaged?) .NET Debug APIs /interfaces

> "Rajasekar Shanmugam" <s_raj...@yahoo.com> wrote in message news:OeAu0nZ9BHA.692@tkmsftngp04...

Reply all
Reply to author
Forward
0 new messages