Click here to Skip to main content
13,190,884 members (51,189 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 22 Jun 2011

Invoking foreign remoting interfaces in remote hosts using C#

, 22 Jun 2011
Rate this:
Please Sign up or sign in to vote.
How to invoke foreign remoting interfaces in remote hosts.

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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Denmark Denmark
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171016.2 | Last Updated 22 Jun 2011
Article Copyright 2011 by ugavnholt
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid