Although new development may be carried out using .Net, there will be a need to reuse some of the functionality existing in the form of COM components. In this article, I examine some COM and .Net interoperability techniques.
COM to .Net: A shift in technologyThough a COM component and a .Net assembly share the same .dll extension, things are not the same internally. A .Net assembly does not need information about it to be stored in the registry, but instead holds the type information in the form of metadata. This metadata is present within the assembly itself. Further, a .Net assembly is not based on the IUnknown interface, which is an interface exposed by all COM objects. The code that exists in the form of COM is known as unmanaged code, because the execution of this code is not managed by the common language runtime (CLR). Code written with the .Net Framework is managed by the CLR and is hence known as managed code. It is impractical to rewrite every piece of code in .Net, because a lot of functionality exists in COM form. Moreover, more code exists in COM today than .Net, because .Net is a relatively new platform. From this fact arises the need for interoperating between COM and .Net. The .Net Framework has dedicated a namespace for this purpose. The System.Runtime.InteropServices namespace provides classes that can be used for accessing COM objects from .Net. We will begin by calling COM objects from .Net -- a common necessity. Calling COM objects from .Net
The code within a COM object is not executed by the CLR. The mechanism followed to expose a COM object to .Net is as follows: The COM object is encapsulated within a wrapper class, and this exposes the COM object as a .Net assembly to the CLR. This wrapper is known as the runtime callable wrapper (RCW). This process is illustrated in Figure A.
| Figure A |
![]() |
| Runtime callable wrapper (RCW) |







Talkback
It would be nice to access your site without that CiscoSystem popup sitting in the middle of your articles. The worst thing is that the damn thing doesn't have a method for closing.
What is that? And WHY?