I have built a desktop app that controls a piece of 3rd party hardware using their provided .dll (I am relatively confident that this is a 64bit .dll since it is running fine in VS2015 compiled with either AnyCPU
or x64
). Everything works just as expected when used as a desktop app.
I am now attempting to expose those same commands as a WCF service to allow a client app to control the hardware remotely. When the client connects I get:
An exception of type 'System.BadImageFormatException' occurred in mscorlib.dll but was not handled in user code
Additional information: Retrieving the COM class factory for component with CLSID {58DB561E-0186-11D5-BBB6-00508B35B332} failed due to the following error: 800700c1 is not a valid Win32 application. (Exception from HRESULT: 0x800700C1).
If there is a handler for this exception, the program may be safely continued.
I am referencing to the same .dll as the desktop app, and calling the same functions. The client is also a 64bit application (currently still running on the same machine). Communication between client-service can already be verified with a simple Hello World function.
What am I missing? Why does the .dll work smoothly in one case and not the other?
Edit:
I can rule out the client application from this, as I can trigger the error using invoke
in the WCF Test Client application that launches from VS2015. This is definitely something wrong with the service application. Also, I can compile it for 32bit or for 64bit and they both give the System.BadImageFormatException
.
System.ServiceModel
and it appears to just be hosted using the debugger on localhost for http access from the client. Moreover, I do not think the .dll the service or the client are 32bit -- I think its 64bit across the board. – samSystem.BadImageFormatException
– sam