"Andy" <aj********@cap citypress.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.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:icorruntimeho st.dll runtimeuser.cs
using System;
using System.Runtime. InteropServices ;
class Tester
{
static void Main()
{
ICorRuntimeHost corRuntimeHost;
object itfDefaultAD = null;
corRuntimeHost = (ICorRuntimeHos t)new CorRuntimeHost( );
corRuntimeHost. GetDefaultDomai n(ref itfDefaultAD);
AppDomain defaultAppDomai n = (AppDomain)itfD efaultAD;
Console.WriteLi ne(defaultAppDo main.FriendlyNa me);
defaultAppDomai n.DoCallBack(ne w CrossAppDomainD elegate(MyCallB ack));
}
static public void MyCallBack() {
string name = Assembly.GetEnt ryAssembly().Fu llName;
Console.WriteLi ne("from " + name);
}
}
[
// CLSID_CorRuntim eHost from MSCOREE.DLL
Guid("CB2F6723-AB3A-11d2-9C40-00C04FA30A3E"),
ComImport
]
public class CorRuntimeHost
{
}
[
// IID_ICorRuntime Host
Guid("CB2F6722-AB3A-11d2-9C40-00C04FA30A3E"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)
]
// Only includes GetDefaultDomai n's signature !!!
public interface ICorRuntimeHost
{
void CreateLogicalTh readState();
void DeleteLogicalTh readState();
void SwitchInLogical ThreadState();
void SwitchOutLogica lThreadState();
void LocksHeldByLogi calThread();
void MapFile();
void GetConfiguratio n();
void Start();
void Stop();
void CreateDomain();
void GetDefaultDomai n([MarshalAs(Unman agedType.IUnkno wn)]ref Object o);
void EnumDomains();
void NextDomain();
void CloseEnum();
void CreateDomainEx( );
void CreateDomainSet up();
void CreateEvidence( );
void UnloadDomain();
void CurrentDomain() ;
}
Willy.