Author Topic: I get a System.BadImageFormatException when using the Hugin .NET API  (Read 21210 times)

Offline Martin

  • HUGIN Expert
  • Hero Member
  • *****
  • Posts: 613
    • View Profile
This is most likely because the compiled assembly does not target the same platform as the referenced Hugin .NET API dll-file. (or any other third-party libraries referenced, if using any).

This will happen if you e.g. reference the x86 Hugin .NET API in an agnostic assembly (compiled with the default /platform:anycpu), and then execute it on the x64 platform.

The compiled assemblies should always target the same platform as the Hugin .NET API dll-file referenced. The compiler option can be set on the commandline by adding /platform:x86 or /platform:x64 as an argument to csc.exe - or from visual studio, by opening the project properties of the c# project, switch to the build-fan and specify either x86 or x64 as target platform.
Hugin Expert A/S

Offline Martin

  • HUGIN Expert
  • Hero Member
  • *****
  • Posts: 613
    • View Profile
Re: I get a System.BadImageFormatException when using the Hugin .NET API
« Reply #1 on: January 15, 2013, 14:29:25 »
If you are using the .NET 4.0 version of the HUGIN API, then you may need to install the VC++ 2010 runtime.

The runtime installation packages can be downloaded from MSDN:

32-bit:
Microsoft Visual C++ 2010 Redistributable Package (x86)
http://www.microsoft.com/en-us/download/details.aspx?id=5555

64-bit:
Microsoft Visual C++ 2010 Redistributable Package (x64)
http://www.microsoft.com/en-us/download/details.aspx?id=14632
Hugin Expert A/S