Roy Osherove

View Original

CreateObject on remote server in .NET

In VB6 you could easily create a COM+/MTS object on a specific server by using CreateObject(progId, serverName).
Corrado Cavalli, an MVP, just pointed this snippet showing how one would do the equivelant of that in .NET:

Dim t as Type=Type.GetTypeFromProgId(progid, servername)
Dim o as Object=
Activator.CreateInstance(t)

Here's a C# version for the VB-Challenged..

Type t = Type.GetTypeFromProgId(progid, servername)
Object o=
Activator.CreateInstance(t)

Cross Posted from Blogs.Microsoft.Co.Il/Blogs/Royo