Calling Com object From C# to add 2 numbers
-
Good Morning, I need to call a dll from C# that was generated by magic edeveloper. I think it is a C dll. It is a program that takes in 3 parameters all integers. Adds the first to and pass the sum to the 3rd parameter. I have registered the dll in windows and I can add a reference in visual studio via the Project Add Reference menu. I have the following code in my project
int a = 5;
int b = 6;
int sum = 0;
double sumDouble = 0;
sumdll.sumdllClass sdc = new sumdll.sumdllClass();
sumDouble = sdc2.sumdll(ref a, ref b, ref sum);But if I run it I get the error
Unable to cast COM object of type 'sumdll.sumdllClass' to interface type 'sumdll.Dsumdll'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3DC9FCBA-9E72-49AA-B597-F9B2603D5EEA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
the following is available from the intellisense
sumdll.sumdllClass sdc = new sumdll.
Dsumdll which is an interface
Sumdll which is an interface
sumdllClas which is a classAnd in the line
sumDouble = sdc2.sumdll(
ref int input1, ref int input2, ref @input)Does anyone know I am getting this error? Or how to call the dll correctly. Regards, Christiaan Pieters
-
Good Morning, I need to call a dll from C# that was generated by magic edeveloper. I think it is a C dll. It is a program that takes in 3 parameters all integers. Adds the first to and pass the sum to the 3rd parameter. I have registered the dll in windows and I can add a reference in visual studio via the Project Add Reference menu. I have the following code in my project
int a = 5;
int b = 6;
int sum = 0;
double sumDouble = 0;
sumdll.sumdllClass sdc = new sumdll.sumdllClass();
sumDouble = sdc2.sumdll(ref a, ref b, ref sum);But if I run it I get the error
Unable to cast COM object of type 'sumdll.sumdllClass' to interface type 'sumdll.Dsumdll'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3DC9FCBA-9E72-49AA-B597-F9B2603D5EEA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
the following is available from the intellisense
sumdll.sumdllClass sdc = new sumdll.
Dsumdll which is an interface
Sumdll which is an interface
sumdllClas which is a classAnd in the line
sumDouble = sdc2.sumdll(
ref int input1, ref int input2, ref @input)Does anyone know I am getting this error? Or how to call the dll correctly. Regards, Christiaan Pieters
Ok so I tried to do the same thing in VB.NET. I usally work in a console application for ease and once I have succeded I will convert or redo what every I have to do. The console application in VB.NET is by default in a module. If I do the following in VB.NET from the module
Console.WriteLine("Start")
Dim dllRef As New sumdll.sumdll() //Only this one method is available… It is indicated as an interfaceDim a As Integer = 10 Dim b As Integer = 18 Dim c As Integer = 0 Dim d As Double = 0.0 d = dllRef.sumdll(a, b, c) Console.WriteLine("Done") Console.WriteLine(a) Console.WriteLine(b) Console.WriteLine(c) Console.WriteLine(d)
Console.Read() But if I move the same code to a class I still get the same error as before. Why can’t this be called from a class? If I can get this to run from a class I am sure I will be able to call this from C#. Thanks, Christiaan
-
Good Morning, I need to call a dll from C# that was generated by magic edeveloper. I think it is a C dll. It is a program that takes in 3 parameters all integers. Adds the first to and pass the sum to the 3rd parameter. I have registered the dll in windows and I can add a reference in visual studio via the Project Add Reference menu. I have the following code in my project
int a = 5;
int b = 6;
int sum = 0;
double sumDouble = 0;
sumdll.sumdllClass sdc = new sumdll.sumdllClass();
sumDouble = sdc2.sumdll(ref a, ref b, ref sum);But if I run it I get the error
Unable to cast COM object of type 'sumdll.sumdllClass' to interface type 'sumdll.Dsumdll'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3DC9FCBA-9E72-49AA-B597-F9B2603D5EEA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
the following is available from the intellisense
sumdll.sumdllClass sdc = new sumdll.
Dsumdll which is an interface
Sumdll which is an interface
sumdllClas which is a classAnd in the line
sumDouble = sdc2.sumdll(
ref int input1, ref int input2, ref @input)Does anyone know I am getting this error? Or how to call the dll correctly. Regards, Christiaan Pieters
-
Good Morning, I need to call a dll from C# that was generated by magic edeveloper. I think it is a C dll. It is a program that takes in 3 parameters all integers. Adds the first to and pass the sum to the 3rd parameter. I have registered the dll in windows and I can add a reference in visual studio via the Project Add Reference menu. I have the following code in my project
int a = 5;
int b = 6;
int sum = 0;
double sumDouble = 0;
sumdll.sumdllClass sdc = new sumdll.sumdllClass();
sumDouble = sdc2.sumdll(ref a, ref b, ref sum);But if I run it I get the error
Unable to cast COM object of type 'sumdll.sumdllClass' to interface type 'sumdll.Dsumdll'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3DC9FCBA-9E72-49AA-B597-F9B2603D5EEA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
the following is available from the intellisense
sumdll.sumdllClass sdc = new sumdll.
Dsumdll which is an interface
Sumdll which is an interface
sumdllClas which is a classAnd in the line
sumDouble = sdc2.sumdll(
ref int input1, ref int input2, ref @input)Does anyone know I am getting this error? Or how to call the dll correctly. Regards, Christiaan Pieters
Well.. Do you try to register this dll in to the GAC?
Thanks Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you. I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.