Chapter 17: COM Interoperability

 
Chapter 17 - COM Interoperability
bySimon Robinsonet al.
Wrox Press 2002
  

Overview

In this chapter we will look at COM interoperability with .NET. COM components and .NET components are not innately compatible because they rely on different internal architectures. Since many organizations rely extensively on COM components for their middle- tier services, it will be important for many .NET solutions to exploit these legacy components. The .NET Framework does indeed provide facilities for manipulating COM components from managed, .NET code, and also consuming .NET components from unmanaged code: code that is not managed by the .NET runtime.

At the heart of COM interoperability is the idea of wrapper classes that translate specific calls from a managed client into COM-specific invocation requests on the unmanaged COM component. Thus a .NET application can be fooled into thinking it is dealing with another .NET component, and a COM component can believe it is dealing with a standard COM-aware client. Conversely, another type of wrapper allows .NET components to be consumed from unmanaged code.

In this chapter, well show you how to achieve interoperability between COM and .NET.

Well start with a brief review of COM, followed by a look at using COM components from .NET, in which we will cover:

  • Early and late binding to COM components and Runtime Callable Wrappers

  • Generating managed metadata wrappers using TlbImp.exe and Visual Studio .NET

  • Examples of early binding and late binding to COM components, and using an ADODB Recordset in .NET

  • Releasing COM objects

  • Using ActiveX controls in .NET

Then, well look at using .NET components from COM clients , and cover:

  • COM-Callable Wrappers, and requirements of .NET classes so they can be used from unmanaged COM clients

  • Binding to a .NET component

  • Exporting type libraries, with RegAsm.exe and TlbExp.exe

Finally, well take a look at platform invocation services, and how .NET can interoperate with unmanaged code in any DLL, such as the Win32 API.

  


Professional C#. 2nd Edition
Performance Consulting: A Practical Guide for HR and Learning Professionals
ISBN: 1576754359
EAN: 2147483647
Year: 2002
Pages: 244

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