I have a 64bit web application written in c# deployed to IIS on both windows server 2008 (IIS 7) and windows server 2012 (IIS 8).
Part of the application involves accessing an unmanaged c++ DLL from c# code. This call is failing when I deploy to IIS. I get the classic:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
I have read many threads on the topic, including:
An attempt was made to load a program with an incorrect format ERROR
But I don't think they apply as
- I have a 64 bit application.
- It's compiled as x64
- It's deployed as x64
- I have verified it is running under an x64 IIS appPool.
- enable32bitapplications is set to false.
- Both the c# dll importing and the unmanaged dll are compiled to 64bit.
- I have deployed to IIS on the server machines in both Release and Debug mode - no difference.
There are 32 bit dlls in the application, but they are in completely separate projects which are not referenced by, nor reference, the project that is throwing the error.
For additional information, it runs fine on both my local machine in IIS express AND my local machine when deployed through IIS (windows 7), so there is a disconnect somewhere and I can't track it down.
Additional info:
The unmanaged DLL does have dependencies on:
- Kernel32.dll
- Advapi32.dll
- Crypt32.dll
- User32.dll
- Version.dll
I realize these are 32bit I thought these were 32bit, but on a 64 bit machine these live in System32, so I'm not sure... but if so, how can I get it to compile as the unmanaged DLL itself is compiled to 64 bit.
Also, why would it work locally for me?
Also, I have (just for kicks and skittles) set Enable32BitApplications to True and I get the same error, as my project is a 64 bit project and references a 64bit unmanaged DLL, which can't run in a 32 bit process.