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 ...

Get .NET Programming: A Practical Guide Using C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.