Engineering scalable systems, cloud-native applications, and AI-powered solutions.

Solution- An unhandled exception of type 'System.BadImageFormatException' occurred in SomeService.exe.

Please check out the root cause and solution for the below error message.

Ankush Jain

Ankush Jain

Lead Software Engineer (VP) | Software Architect

Published Feb 6, 2020Updated Nov 24, 2026

Please check out the root cause and solution for the below error message.

Error Message

An unhandled exception of type 'System.BadImageFormatException' occurred in SomeService.exe.
Additional information: Could not load file or assembly 'SomeAssembly, Version=1.0.0.XXXXX, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Problem (Root Cause)

It seems like you have taken the reference of any assembly whose target platform is x64 and your current project's target platform is x86 (32 bit) or vice versa.

Solution

To fix the issue, you have to make sure that your current project and the DLL your project is referencing, both should have the same target platform.

Have feedback or thoughts?

Discuss this article or share it on Twitter / GitHub.