Could Not Load File or Assembly 'Xxx' or One of Its Dependencies. an Attempt Was Made to Load a Program with an Incorrect Format

Could not load file or assembly 'xxx' or one of its dependencies. An attempt was made to load a program with an incorrect format

Sounds like one part of the project is being built for x86-only while the rest is being built for any CPU/x64. This bit me, too. Are you running an x64 (or uh... IA64)?

Check the project properties and make sure everything is being built for "Any CPU". f you're in Visual Studio, you can check for everything by going to the "x86" or "Any CPU" menu (next to the "Debug"/"Release" menu) on the toolbar at the top of the screen and clicking "Configuration Manager..."

Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException)

I am pretty sure you're having a 32-bit / 64-bit conflict. It sounds like your main project might be set to 32-bit while the class its referencing is set to 64-bit. Try looking at this SO question and this one too. Between the two of them, you should be able to figure out your problem.

Could not load file or assembly xxx or one of its dependencies. An attempt was made to load a program with an incorrect format.

It sounds like your Oracle.DataAccess dll is a 64 bit dll. You can see what driver is loaded on the web server by navigating in Windows Explorer to the \windows\assembly folder.
Sample Image

Most applications that are built with the Any CPU option will have the checkbox in the project settings to prefer 32 bit. To avoid this, change your project's platform target to be a 64 bit.

Sample Image

Then you do not need to "Enable 32 bit" in your application pool and your problem should disappear. Please let me know if this helps.

Could not load file or assembly exception

Ok the answer is Got to Start->Run->type inetmgr and on the left application pools, select DefaultAppPool and the virtual directory name of the app and for both make sure to enable 32 -bit applications to true, am using IIS7.0 and windows 7 64-bit.
Sample Image



Related Topics



Leave a reply



Submit