Invoking the Default Host: Activating Managed Types Through COM Interop


The Microsoft .NET Framework software development kit (SDK) includes a tool (regasm.exe) you can use to make managed types available through COM. In this way, a managed type can be brought into a process using any of the existing COM APIs. regasm.exe works by creating the registry entries necessary to make the type visible to COM. The default host for managed types activated in this way is also implemented in the CLR startup shim (mscoree.dll). In this scenario, the default host is activated because regasm.exe sets the CLR startup shim as the InProcServer32 key under the COM registry entries for all managed types. Figure 4-1 shows the registry entries that regasm.exe would make to allow the managed type System.Collections.SortedList to be activated through COM.

Figure 4-1. Registry entries that expose a managed type to COM


When an instance of System.Collections.SortedList is created through COM, the shim loads the CLR in the process and returns a class factory through which COM can create the type. The CLR determines which type it needs to create by looking back in the registry for the globally unique identifier (GUID)/ProgID requested by COM. Notice in Figure 4-1 that regasm.exe adds some custom registry values under the InProcServer32 key for a managed type. These values include the name of the type to create and the assembly in which the type is implemented.



    Customizing the Microsoft  .NET Framework Common Language Runtime
    Customizing the Microsoft .NET Framework Common Language Runtime
    ISBN: 735619883
    EAN: N/A
    Year: 2005
    Pages: 119

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net