问题
I have received this error after updating to Windows 7 64-bit and then running an existing .NET Website.
[InvalidOperationException: Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.]
I have only installed the 32-bit Oracle Client installed and I understand that on my 64-bit development machine the application is expecting 64-bit libraries UNLESS explicitly stated. This is from the searching I have done so far.
I have read that I can change the Solution Platform to x86 which will instruct the application to use 32-bit if that's what it finds. I would like to do this but there is no x86 option for the Website in the Visual Studio solution.
I created the a test application and I have the option, I created a test website and it didn't. How can I compile a website to x86 so that it will use the 32-bit Oracle Client.
Cheers
回答1:
In IIS Manager, create an Application Pool and set that Application Pool to run in 32-bit mode. Then assign your website using 32-bit Oracle Client to run in that 32-bit Application Pool.
Because the worker process that IIS starts for that Application Pool is a 32-bit process, when it tries to load the CLR it will load the 32-bit CLR and therefore will load your assembly in 32-bit mode. This is true even if your assembly was compiled for 64-bit and 32-bit modes. Your assembly running in 32-bit mode can then call the Oracle Client running in 32-bit mode.
来源:https://stackoverflow.com/questions/1707101/how-to-compile-a-website-to-use-32-bit-oracle-client-on-64-bit-windows