In current project, I had to use some 3rd party APIs, which is exposed via COM Interop. I found some VB.Net code to consume, but I couldn’t find in C# implementation for the same. Here is the code snippet which is equivalent VB.Net CreateObject method.
var txt = "HelloWorld"; var type = Type.GetTypeFromProgID("vbscript.regexp"); dynamic vbScriptRegEx = Activator.CreateInstance(type); vbScriptRegEx.Pattern = "l"; Console.WriteLine(vbScriptRegEx.Replace(txt, "##"));
You may get some other errors, if your platform / platform target is different from the COM object compiled platform.