Coder Perfect

System.BadImageFormatException: Could not load file or assembly [duplicate]


C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe C:\_PRODUKCIJA\D
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\_PRO
DUKCIJA\Debug\DynamicHtmlTool.exe' or one of its dependencies. An attempt was ma
de to load a program with an incorrect format..


Even though both PCs are x64, the service is compiled for x86 and runs on my computer. This problem occurs on the server where Windows 2008 is installed.

I tried several Google solutions, but none of them worked.

Like write here i have x86 project

Asked by senzacionale

Solution #1

It appears that you are trying to install a 32-bit/x86 architecture application with the 64-bit version of the tool. The tool’s 32-bit version can be found here:


and it should successfully install your 32-bit application.

Answered by madd0

Solution #2

It’s generally related to x86/x64 architectural issues, thus try to adjust the settings of your projects:

Go and set your choice as shown:

Answered by David

Solution #3

I came up with a different approach to this problem. My Application Pool in IIS 7 did not appear to have 32bit mode enabled by default.

Open IIS and pick your Application Pool to enable 32bit mode. “ASP.NET v4.0” was the name of my project. Change the section under “Enabled 32-bit Applications” to true by right-clicking and going to “Advanced Settings.”

Restart your web server and give it another shot.

This blog post helped me figure out how to fix it:

Visual Studio is a software development environment. In my case, I checked the box under Tools > Options > Projects and Solutions > Web Projects. Use the 64 bit version of IIS Express for web sites and projects – This was on VS Pro 2015. Nothing else fixed it but this.

Answered by Joseph Snow

Solution #4

I encountered the same problem when I installed the right framework.

Running cmd as administrator was my solution, and it worked perfectly.

Answered by woony

Solution #5

My cause was unique. After referencing a web service, I received this message.

Then I shifted my focus. .NET Framework 4.0 to.NET Framework 4.0 to.NET Framework 4.0 to Re-refer my webservice using Net Framework 2.0. After a few tweaks, the issue was resolved. There was no problem, and everything worked perfectly.

hope this helps!

Answered by Davut Gürbüz

Post is based on