Registering the Assembly with COM

Snoops

   

 
Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET
By Dhananjay  Katre, Prashant  Halari, Narayana  Rao  Surapaneni, Manu  Gupta, Meghana  Deshpande

Table of Contents
Chapter 9.   Migrating to Visual C++ .NET


At runtime the COM knows where to find the libraries and how to instantiate them from the settings in the System Registry. A .NET assembly does not have the standard built-in registry functions. Hence, by just pointing a COM tool at an assembly, you cannot expect it to register the library with COM. Instead a tool is required that will look into the metadata and make the appropriate entries in the registry. This tool is called the register assembly tool ( regasm.exe ) and it can be used to generate the type library information for the assembly in one step using the /tlb: switch. The following example illustrates how to generate the type library and register the type library and the component in one step:

 regasm Test.dll /tlb: Test.tlb 

Alternately this can be done in two steps by using the type library export ( tlbexp.exe ) utility and then using the regasm.exe. If the tlbexp.exe tool is used, one has to also use the regasm.exe because tlbexp will generate the type library but will not register it. Registration of the type library will have to be done separately by the regasm.exe tool. So we can see that it will be more convenient for developers to use the regasm.exe with the /tlb option because both creation and registration of the type library is achieved by a single tool instead of using two separate commands.

This will register all the COM creatable types in the assembly as coclasses and all public interfaces as COM interfaces, and it will also register the type library. In addition it will make registry entries as the ProgID and the CLSID. Once the coclasses are registered, they are associated with the mscoree.dll runtime assembly instead of the assembly that contains the components . Ultimately it is the runtime's headache to locate the assembly's actual implementation for the components.


Snoops

   
Top


Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
Migrating to. NET. A Pragmatic Path to Visual Basic. NET, Visual C++. NET, and ASP. NET
ISBN: 131009621
EAN: N/A
Year: 2001
Pages: 149

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