Calling dll from C#

Dec 3 2009 12:17 AM
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 class

And 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,
Steven Smtih

Answers (1)