I already have a native code COM object, and am trying to instantiate it from C#. The Com is registered in DCOM components and in the registry.
This is what I'v try to do:
public static void Main(string[] args)
{
Type t = Type.GetTypeFromProgID("CaseConsole.Application");
dynamic app = Activator.CreateInstance(t);
dynamic c = app.Case;
c.OpenCase("17-16", 0);
}
If I try to instantiate the com-type then, I get the:
NotImplementedException
The execption is thrown at line:
dynamic c = app.Case;
As I set a breakpoint at this line, I'v looked into "app" and the error was already present
I'v looked in the Type t and it shows: IsCOMObject = true
As VBS it works great:
Dim App
Dim c
Set App = CreateObject ("CaseConsole.Application")
Set c = App.Case
c.OpenCase "17-16", 0
As VB.net it works
Sub Main()
Dim App
Dim c
App = CreateObject("CaseConsole.Application")
c = App.Case
c.OpenCase("17-16", 0)
End Sub
but not in C#
For the C# example I looked at the sources from
http://www.codeproject.com/Articles/990/Understanding-Classic-COM-Interoperability-With-NE
https://msdn.microsoft.com/en-us/library/aa645736%28v=vs.71%29.aspx
Equivalent code of CreateObject in C#
My guess is that i must invoke the methods with InvokeMember or a security thing...
Please can you help to get the c# example working?
Update rename case to c but that wasn't the fault.