Understanding COM and .NET Interoperability
|
|
Moreover, you do not need to make use of the other components entirely. .Net has the capability to use even a small part of other components with your existing code. The flexibility or the interoperability between COM and .Net allows you to either use COM component from .Net or use .Net components from COM. To use COM components from .Net there is a tool that takes a COM component or type library and creates a managed assembly also called Runtime Callable Wrapper (RCW). This wrapper assembly is the DLL file created by tlbimp.exe or the VS.NET IDE. Similarly to use .Net components from COM you can use the wrapper class that organizes the COM calls through to the managed code. In addition, you should create interfaces for .Net components to be available in COM. These interfaces can be created either manually or automatically.
You can make use of existing COM components by using late-bound and early-bound references. Both late-bound and early-bound references are objects that are created and set to object types. The difference between them is that late-bound reference is set to object type at runtime and early-bound reference is set to object type at design time. Moreover, the late-bound COM reference is used by writing Server.CreateObject() method and the early-bound COM reference uses a built-in utility that creates a proxy class.