createObject of vbs vs Activator.CreateInstance of C#

119 Views Asked by At

I need to convert a vbs to C# application

The vbs contains the creation of a new object and it works

Set dllApp = CreateObject("MGCPCBReleaseEnvironmentLib.MGCPCBReleaseEnvServer")

I read that by using Activator.CreateInstance I can have the same result (if not please explain).

Type t = Type.GetTypeFromProgID("MGCPCBReleaseEnvironmentLib.MGCPCBReleaseEnvServer");
dynamic m = Activator.CreateInstance(t);

When i run this code there is an exception:

retrieving the COM class factory for component with CLSID ... failed due to the following error: ... Class not registered

When I run the vbscript on the same machine it works fine. What is the difference between the C# implementation and the vbscript implementation?

0

There are 0 best solutions below