Asp.net / IIS7 : System.BadImageFormatException: Could not load file or assembly

You have something like this:


Server Error in '/Vendorapplication' Application.
Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

It's because you are trying to run 32 bit dlls on a 64 bit system. Fix it in IIS manager by changing the advanced settings on you application pool to enable 32 bit applications. Or create a new app pool specifically for them.

Alex James Brown has a nice picture: change app pool to 32 bit

There is a duplicate system.web.extensions/scripting/scriptResourceHandler section defined

Scenario:
You've been working with no problems probably in VS2008 on web app written on .net 2 or .net 3.5 or .net 3.5 sp1 and then you try running on a machine with windows 7 or vista running IIS7 and you get this error message...
Simples. It's comes of running your .Net 2 (you did know that a .Net 3.5 app actually runs on .Net 2 didn't you?) app under .Net 4. Fix it by changing the app pool for your web app to the pre-defined "Classic .Net App Pool", which runs .Net framework 3
Run a dotNet 2 or dotNet 3 or dotNet 35 app under IIS7

Bob Martin’s eliminate boolean arguments tip – an example

I don't always agree with Bob Martin's Clean Code Tip #12: Eliminate Boolean Arguments - probably because the mathematician in me believes that there are such things as functions of a boolean value - but I came across an example in a WinForms app today where I'd apply it.

void FindApplicant(int id)
{
    processUIChange(true);
    applicant= getTheApplicantFromDataLayer(id);
    processUIChange(false);
}

turned out to mean:

void ProcessUI(bool processing)
{
    if(processing)
    {
      this.Enabled=false;  
    }
    else
    {
       ... do a whole load of stuff
    }
}

which would have been easier to read as:

void FindApplicant(int id)
{
    DisableUIWhileUpdating();
    applicant= getTheApplicantFromDataLayer(id);
    UpdateUIAfterDataChange();
}

void DisableUIWhileUpdating()
{
    this.Enabled=false
}
void UpdateUIafterDataChange()
{
    ...do a whole load of stuff
}