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
C#
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
VB.NET
Unable to cast COM objectof 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
VB.NET
sumdll.sumdllClass sdc = new sumdll.
Dsumdll which is an interface
Sumdll which is an interface
sumdllClas which is a class
Does anyone know I am getting this error? Or how to call the dll correctly. Regards, Steven Smtih
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Sam HobbsRank #107 · 20.5K reputationPosted Dec 3, 2009, 7:32 AM EST
0
VB programmers are in the bad habit of calling COM objects DLLs because VB prior to .Net could not create regular DLLs so, for VB programmers, all DLLs are COM objects that need to be registered. A regular DLL does not have type information and therefore registration is useless for them. Are you sure that the DLL is not a regular DLL? Assuming that the DLL is a COM object, you should not call it a DLL since that is confusing since DLL implies regular DLL. Call it a COM object or something like that. Refer to the documentation if necessary to determine what type of object it is.
Assuming that the DLL is a COM object or something that has type information, then you need to refer to the documentation. If the documentation specifies how to use the object in a manner you are overlooking, then it is likely not possible for anyone to know what the problem is.
Sam HobbsRank #107 · 20.5K reputationPosted Dec 3, 2009, 7:32 AM EST
Assuming that the DLL is a COM object or something that has type information, then you need to refer to the documentation. If the documentation specifies how to use the object in a manner you are overlooking, then it is likely not possible for anyone to know what the problem is.