Need for Interoperability between .NET and 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 10.   Dealing with Legacy Components in .NET


Microsoft .NET is a great improvement compared to the COM technology. It brings us nearer to true code reusability. However, many organizations have invested huge amounts in building COM components. COM has been in the market for almost seven years , and the last decade saw a substantial growth of the IT industry in various segments, which means that there has been a lot of code packed in the form of components. So, it is impracticable to rewrite the entire code into .NET components, however good they may be for designing more robust applications. Existing applications using COM components have already been tested , and, if one were to shift to .NET components, this testing would have to be carried out again. So, there is a great need for interoperability between the COM and .NET components.

Table 10-3. Differences between COM and .NET

COM

.NET

Promotes functionality reuse.

Advocates code reuse.

Global access of components on a machine.

No global access.

Registering DLLs is required.

No registration required.

Registry information and DLLs are stored at two different locations.

All information required to identify version and others is stored at a single location.

Difficult to understand.

Easy to understand.

Run under an unmanaged environment.

Runs under a managed environment.

Server restarts required for ASP applications.

No server restarts. Promotes side-by-side deployment of the applications.

Languages and tools take priority while developing COM.

No priority for a language or a tool under .NET.

Strong affinity to Windows operating systems.

Independent of operating system.

The success of COM to a certain extent depends on the threading model used to design the COM, which varies from tool to tool. Visual Basic supports two threading models, whereas Visual C++ supports four threading models.

In .NET, the process is simplified and by default the .NET components under Windows 2000 server are neutral threaded. Components (new in Windows 2000 with COM+) allow multiple instances of objects to be created like apartment-threaded components. However, they don't limit each instance to always working in the same process and so can be shared among requests .

The following tools provide interoperability between .NET and COM:

  • Type Library Importer ( tlbImp.exe ) . Converts the type definitions found within a COM type library into equivalent definitions in managed metadata format.

  • Type Library Exporter ( tlbExp.exe ) . Uses a managed assembly as input, generates a type library containing COM definitions of the public types defined in that assembly.

  • Assembly Registration Tool ( regAsm.exe ) . Enables classic COM clients to call managed classes. RegAsm reads the metadata within an assembly and then adds the necessary entries to the registry. Therefore, classic COM clients can create the managed classes transparently .

  • ActiveX Control Importer ( aximp.exe ) . Uses an ActiveX control's type library as input and generates a wrapper control that allows the ActiveX control to be hosted by Windows Forms.


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