My company uses a 3rd-party DLL to interface to some hardware (I've renamed it hwLib
here). It was written long ago in VB6, I think. The DLL comes with an installer to register itself, etc.
We have a C# app that uses it and which runs just fine on XP and Win7, 32 or 64 bit. But I wrote a simple C++ console app which runs fine on XP/32 bit but crashes on Win7/64 bit.The console app looks like this,
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
using namespace hwLib;
ChwLib^ myLib = gcnew ChwLib();
String^ str = myLib->GetDllVersion();
Console::WriteLine(L"Hello hwLib");
Console::WriteLine(str);
Console::ReadLine(); //to keep window open til you hit the "any" key
return 0;
}
Unhandled Exception: System.InvalidCastException: Unable to cast COM object of type 'hwLib.ChwLibClass' to interface t ype 'hwLib._ChwLib'.
This operation failed because the QueryInterface call on the COM component for the interface with IID '{E0560D1E-9A54-4EBF-83E8-D7BD2C936512}' failed due to the following error:
No such interface supported (Exception from HRE SULT: 0x80004002 (E_NOINTERFACE)). at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease) at hwLib.ChwLibClass.GetDllVersion() at main(String[] args) at mainCRTStartupStrArray(String[] arguments)
The C# program, which is a much bigger and more complex program, else I would post it here, runs without problems on the same system.
COM is before my time - I took a course in it maybe 10 or 15 years ago but I don't remember it - Any suggestion on how to start debugging this? Thanks!!