Game Development Reference
In-Depth Information
Registering with COM
After your .NET component is compiled, you have to generate a type library file
( .tlb ) so that COM clients can consume and invoke the new functionality. There
are a couple of ways to do this.
The first approach is to use the type library exporter utility (tlbexp.exe) to convert
the exposed classes and interfaces into a COM type library. This approach creates
a type library, but does not register the COM component in the registry. This step
must be performed elsewhere.
Another approach is to use the TypeLibConverter class in the System.Runtime.
InteropServices namespaces to programmatically generate a type library. This
class produces the same output as the type library exporter utility.
A third approach is to use the .NET services installation tool (regsvcs.exe), which
can generate, register, and install type libraries into existing COM+ 1.0 applica-
tions, in addition to loading and registering assemblies.
One of the easiest ways is to use the assembly registration tool (regasm.exe) which
generates a type library using the /tlb switch, but it also places the appropriate
entries into the Win32 registry to make COM clients aware of the component. The
following line shows how to generate a type library for a .NET component and
install it into the Win32 registry.
regasm.exe MyComponent.dll /tlb:MyComponent.tlb
You can automatically perform this step during the build process in the Visual
Studio IDE by enabling Register for COM Interop in the Build project page, as
shown in Figure 32.3.
Figure 32.3 The Register for COM Interop property in the Visual Studio IDE Build page.
We can use the Microsoft Oleview utility to inspect the generated type library to see
what is there. Figure 32.4 shows Oleview inspecting the type library for MyComponent.
Search Nedrilad ::




Custom Search