I have an exe file “ClarityII.exe” supplied by the vendor of a weather monitoring product (Boltwood Cloud Sensor II). The app provides a GUI for displaying and controlling the sensor state, and provides a COM interface to integrate with other software. So far I’m not getting any help from the vendor. I believe it was written in VB6.
I’m trying to make use of the COM interface from a VS2013 .NET 4.5.1 C# program. The vendor supplied a very simple VB6 test ap which works fine.
I have added the required clarityII reference to my C# project. The reduced code below compiles, and when I run it the vendor’s GUI is displayed as expected, but I get the exception below.
The exception occurs when cloudII is created using new:
An unhandled exception of type 'System.InvalidCastException' occurred in Interop1.exe
Additional information: Unable to cast COM object of type 'System.__ComObject' to interface type 'ClarityII.CloudSensorII'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{ XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX }' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
What is likely to be causing this error? I thought the interop was done for me by the compiler automatically producing the wrapper Interop.ClarityII.dll?
I have the following skeleton
using System;
using ClarityII;
class MainClass
{
[STAThread]
public static void Main(string[] args)
{
ClarityII.CloudSensorII cloudII;
cloudII = new ClarityII.CloudSensorII();
}
}
PS edit: I just ran my C# program on another PC with the same ClarityII.exe installed. On that PC there is no exception when I instantiate the COM object. I can also access properties OK. Any ideas what could be broken on my dev PC?