C# Programming
01-16-2010, 08:42 AM
How can I get list of Application Domains?
Following code not get created domain when call from different Win Application.
private static AppDomain GetAppDomain(string pFriendlyName)
{
IntPtr p_Handle = IntPtr.Zero;
//CorRuntimeHostClass Assembly --> C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscoree.tbl
CorRuntimeHostClass runtime = new CorRuntimeHostClass();
try
{
runtime.EnumDomains(out p_Handle);
do
{
object domain = null;
runtime.NextDomain(p_Handle, out domain);
if (domain == null)
{
break;
}
AppDomain appDomain = (AppDomain)domain;
if (appDomain.FriendlyName.Equals(pFriendlyName))
{
return appDomain;
}
} while (true);
}
finally
{
runtime.CloseEnum(p_Handle);
Marshal.ReleaseComObject(runtime);
runtime = null;
}
return null;
}
Following code not get created domain when call from different Win Application.
private static AppDomain GetAppDomain(string pFriendlyName)
{
IntPtr p_Handle = IntPtr.Zero;
//CorRuntimeHostClass Assembly --> C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscoree.tbl
CorRuntimeHostClass runtime = new CorRuntimeHostClass();
try
{
runtime.EnumDomains(out p_Handle);
do
{
object domain = null;
runtime.NextDomain(p_Handle, out domain);
if (domain == null)
{
break;
}
AppDomain appDomain = (AppDomain)domain;
if (appDomain.FriendlyName.Equals(pFriendlyName))
{
return appDomain;
}
} while (true);
}
finally
{
runtime.CloseEnum(p_Handle);
Marshal.ReleaseComObject(runtime);
runtime = null;
}
return null;
}