Is there a manual way to call a COM object in the GAC in .NET, without adding it as a reference?
The reason I ask is I only know how to code in C# and want to call a .NET COM object and tests that its CMO calls are visible, but obviously you can't add a .NET COM object to a .NET assembly! As you have to reference it, so I was wondering can you call it if its registered in the GAC manually through c# code?
Type myType = Type.GetTypeFromProgID("IMyLib.MyClass");
object obj = Activator.CreateInstance(myType);
object[] args = new object[2];
args[0] = "Hello";
args[1] = 3;
myType.InvokeMember("MyMethod", BindingFlags.InvokeMethod, obj, args);
In .Net 4 something like this
Type myType = Type.GetTypeFromProgID("IMyLib.MyClass");
dynamic obj = Activator.CreateInstance(myType);
obj.MyMethod("Hello", 3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With