MarthinusSwart.com

Instantiate DCOM from C#

Because of the amount of legacy COM/DCOM code in the IT world today it is inevitable that at some point a C# class needs to communicate with a DCOM class.

The code snippet below is a quick way to instantiate a DCOM object on another machine.

Guid guid = typeof (DCOMLib.DCOMClass).GUID;
String server = "machinecity";
Type type = Type.GetTypeFromCLSID(guid, server, true);
Object dcomObj = Activator.CreateInstance(type);