I'm using c# do build a few libraries which we then use from within Matlab 64bit. The c# library is compiled to 64bit so that we can use it from Matlab. The c# library uses an interop to call a COM component which is legacy 32bit code. When running the tests in c# everything works but if I use the library from Matlab I get the following error:
Message: Unable to cast COM object of type '...' to interface type '...'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{...}' failed due to the following error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). Source: mscorlib
To me it looks like the runtime is looking for the 64bit of the COM class but I don't understand why but afaik visual studio 2017 is still 32 bit thats why it is picking the right COM. Any help is welcome.
UPDATE
I tried to run the code using a 64bit test loaded and I get the same error, so it was running from VS because it is 32bit. Having identified that, is there a way to force a 64bit execution context to call 32bit COM components?
Thanks
User contributions licensed under CC BY-SA 3.0