I recently had to connect to an unmanaged COM Remoting service on a remote system, using C# and VS 2010. It turned out to be quite a hazzle, so hoping to save someone's day, here is how it's done.
The COM interface I needed was exposed by a .exe file called ovpmad.exe - the vendor did not provide any files to ease the process, so that was all that I had.
The first step is to extract the interface definition, which is stored in a .IDL file. There are numerous utilities for doing this, I used OleView.Exe from the Windows SDK.
The resulting .IDL file needs to be compiled into a .TLB file, which can be imported into a VS .NET project - another tool from the Win SDK "midl.exe" can be used to do this; in my case, a lot of forward declarations were missing in the IDL file, which I had to fix manually to get through the MIDL compilation.
Having the TLB file is the key, it can be added as a reference to the project, and it can be used to register the remoting interface on the client. The SDK utility "regtlibv12.exe" can be used for the registration, setting up all the Registry entries needed.
Finally, the interface can be invoked, as illustrated in the following example:
Type theType = Type.GetTypeFromProgID("pmad.OvPmdPolicyManager.1", remoteHostName);
Object obj = Activator.CreateInstance(theType);
pmad = (OVPMADLib.IOvPmdPolicyManager) obj;
System.Array RootGroups = pmad.GetTopGroupList();
for (int i = 0; i < RootGroups.GetUpperBound(0); i++)
IOvPmdPolicyGroup group = (IOvPmdPolicyGroup)RootGroups.GetValue(i);
In this example, the variable
remoteHostName is the server address, and
pmad.OvPmdPolicyManager.1 is the name of the remoting interface.
If needed, the Windows utility dcomcnfg can be used to configure rights on the DCOM server.