Wednesday, January 16, 2013

System.BadImageFormatException

Scenario:
  • I've built a .NET 4.0 Windows Forms app...
  • I've added it to a .NET 4.0 Setup project...
  • My DEV PC has .NET 4.0 Framework installed...
  • When I attempt to install the resultant .msi, I get an error message...
System.BadImageFormatException: Could not load file or assembly...This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Setup:
  • On a DEV VM
  • 32 bit
  • Windows 7
  • Visual Studio 2010.

Resolution:
  • The Setup project has a folder for Detected Dependencies...
  • In there is listed Microsoft .NET Framework...
  • When you double-click that, you get a Launch Conditions window...
  • Under Launch Conditions, is listed the .NET Framework version...
  • This was set incorrectly.