"Andy" <aj********@capcitypress.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,
I was wondering if it was possible to get the Entry assembly for the
default application domain (and how to determine what the default app
domain is..).
I'd like to get to it for logging purposes, and it would be nice it the
object can discover that one its own, instead of trusting that a string
it was passed is actually the name of the application.
Thanks
Andy
Following illustrates Richard's point.
// csc /r:icorruntimehost.dll runtimeuser.cs
using System;
using System.Runtime.InteropServices;
class Tester
{
static void Main()
{
ICorRuntimeHost corRuntimeHost;
object itfDefaultAD = null;
corRuntimeHost = (ICorRuntimeHost)new CorRuntimeHost();
corRuntimeHost.GetDefaultDomain(ref itfDefaultAD);
AppDomain defaultAppDomain = (AppDomain)itfDefaultAD;
Console.WriteLine(defaultAppDomain.FriendlyName);
defaultAppDomain.DoCallBack(new CrossAppDomainDelegate(MyCallBack));
}
static public void MyCallBack() {
string name = Assembly.GetEntryAssembly().FullName;
Console.WriteLine("from " + name);
}
}
[
// CLSID_CorRuntimeHost from MSCOREE.DLL
Guid("CB2F6723-AB3A-11d2-9C40-00C04FA30A3E"),
ComImport
]
public class CorRuntimeHost
{
}
[
// IID_ICorRuntimeHost
Guid("CB2F6722-AB3A-11d2-9C40-00C04FA30A3E"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )
]
// Only includes GetDefaultDomain's signature !!!
public interface ICorRuntimeHost
{
void CreateLogicalThreadState();
void DeleteLogicalThreadState();
void SwitchInLogicalThreadState();
void SwitchOutLogicalThreadState();
void LocksHeldByLogicalThread();
void MapFile();
void GetConfiguration();
void Start();
void Stop();
void CreateDomain();
void GetDefaultDomain([MarshalAs(UnmanagedType.IUnknown)]ref Object o);
void EnumDomains();
void NextDomain();
void CloseEnum();
void CreateDomainEx();
void CreateDomainSetup();
void CreateEvidence();
void UnloadDomain();
void CurrentDomain();
}
Willy.