Exposing .NET Components to COMCOM

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents
Chapter 8.  Component Services


Exposing .NET Components to COM/COM+

When COM+ was developed, COM was the prevalent component development technology. Therefore, COM+ was developed with COM in mind. COM+ recognizes only COM components; any .NET component that is exposed to COM+ must be exposed as a COM component.

Calling a .NET Component from COM/COM+

For COM+ (or any COM client) to find a .NET component, you need to register the .NET component as a COM server in the Windows Registry. This process is known as the assembly registration process, and it can be performed by any of the following methods:

  • When using Visual Studio .NET, open the project's property pages and change the Register for COM Interop option to True.

  • Use the Assembly Registration tool (regasm.exe) that ships as a part of the .NET Framework.

  • In a program, use the RegistrationServices class of the System.Runtime.InteropServices namespace.

Before you use any of these options, you must sign a .NET assembly using the Strong Name tool (sn.exe).

Exporting .NET Components As COM Type Libraries

The .NET Framework also enables .NET programmers to export their components as COM type libraries. A type library is a persistent COM Callable Wrapper (CCW) that makes the .NET types available to the COM programs at compile time. COM programmers can use the type information stored inside CCW to compile their programs and take advantage of early binding to the .NET types. Early binding significantly reduces the time required to access an object and additionally enables compilers to enforce type checking at compile time.

A .NET type can be exported as a COM type library in any of the following ways:

  • In Visual Studio .NET, open the project's property pages and change the Register for COM Interop option to True. The Register for COM Interop option is in the Configuration Properties, Build page of the project's Property Pages dialog box.

  • Use the Assembly Registration tool (regasm.exe) with its /tlb option.

  • Use the Type Library Exporter tool (tlbexp.exe) that ships as a part of .NET Framework SDK.

  • In a program, use the ConvertAssemblyToTypeLib() method of the TypeLibConverter class in the System.Runtime.InteropServices namespace.


    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

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