O'Reilly logo

.NET Programming: A Practical Guide Using C# by Pradeep Tapadiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing COM Components from .NET

The companion Web site contains a project called Test to build a DLL-based COM component that we will use for our demonstrations. The executable is named test.dll. Here is some relevant information about the component, taken from its IDL file:

// Project ComFromNet/Test

[
     uuid(653E70B3-4243-4A25-B713-0BFA7A271D02),
     oleautomation,
     ...
]
interface IMyFoo : IUnknown {
     HRESULT GetGreeting([in] BSTR user, [out] BSTR* greeting);
};

[
     uuid(B879FF11-EEAF-474C-B28C-F214B893A4B7),
     version(1.0),
     ...
]
library TestLib
{
     [uuid(FADA4A73-76DC-443C-838E-E6B98251E428)]
     coclass MyTest
     {
        [default] interface IMyFoo;
     };
};

As can be seen from the IDL definition, the component exposes a COM class MyTest that implements a COM interface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required