|
How Do I... Get Started Using Interoperability?The common language runtime's COM interoperability services make it possible to use existing COM objects from within mananged applications and expose mananged objects to exisitng COM applications. Note: Managed code is code that targets the common language runtime. In addition, the runtime's platform invoke mechanism makes it possible to call functions exported from unmanaged DLLs. One of the QuickStarts in this area is devoted to demonstrating COM interoperability and platform invoke.
COM InteroperabilityCOM interoperability provides support for producing and consuming COM objects from mananged code. Objects that are intended to be consumed by COM applications must be designed with interoperability in mind right from the start. Before a type can be consumed by a COM application, the type must meet the following requirements.
See the How Do I...Build a .NET Server Callable from COM clients? topic for details on the build process. COM interoperability provides mechanisms that make it possible to use COM objects from managed code as well. This is the mechanism that runtime clients use to access the services provided by COM objects. Before any managed client can reference a specific COM type, the type must be described in metadata. See the How Do I...Build a .NET Client That Uses a COM Server? topic for details on obtaining an assembly containing metadata for the COM types and the build process. Platform InvokeThe platform invoke service makes it possible to call functions that are exported from an unmanaged DLL. Using platform invoke is similar to calling the LoadLibrary and GetProcAddress Win32 API functions, which call into an exported funtion. It is also similar to using a Declare statement in Visual Basic. Each exported function being called must have a managed method defintion. The method definition can be provided as part of any class and is attributed with the DllImport attribute in C# or with Declare statement in VB.NET to indicate that the method is implemented in unmananged code. See the How Do I...Call a Function Exported From an Unmanaged Library? topic for details on the platform invoke syntax.
|