Type type = Type.GetTypeFromProgID(progId, serverName); if (type == null) throw new Exception("Unable to find the object, ensure the type library is registered"); Object objTest = Activator.CreateInstance(type); ComObject comObject = (ComObject)objTest;
Tuesday, May 30, 2006
DCOM from .NET
It's not well advertised but it is possible to use DCOM from .NET. It may not be as popular as the more recent RPC mechanisms but I still need to use it occasionally. So here's some C# code that should do the trick. The COM type library must be registered on the client machine. ComObject is the type of the COM object that you've imported into an interop assembly.