System.BadImageFormatException:无法加载文件或程序集

sen*_*ale 212 c# 64-bit

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe C:\_PRODUKCIJA\D
ebug\DynamicHtmlTool.exe
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..

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>
Run Code Online (Sandbox Code Playgroud)

服务是x86编译,即使两台计算机都是x64,它可以在我的计算机上运行.在服务器哪里是win 2008我得到这个错误.

我试试谷歌的解决方案但没有工作.

就像写在这里我有x86项目 http://www.davesquared.net/2008/12/systembadimageformatexception-on-64-bit.html

mad*_*dd0 253

您似乎正在使用该工具的64位版本来安装32位/ x86架构应用程序.在这里查找该工具的32位版本:

C:\Windows\Microsoft.NET\Framework\v4.0.30319
Run Code Online (Sandbox Code Playgroud)

它应该安装你的32位应用程序就好了.

  • 或者将Visual Studio(编译器设置)中的目标从"X86"更改为"任何CPU". (53认同)

Dav*_*vid 125

尝试配置项目的设置,通常是由于x86/x64架构问题:

如图所示,设置您的选择:

  • 我不得不嘲笑截图中的菜单栏. (51认同)
  • **测试>测试设置>默认处理器架构> x64**为我工作. (3认同)

Jos*_*now 106

我发现了一个不同的解决方案.显然,我的IIS 7默认情况下在我的应用程序池中没有启用32位模式.

要启用32位模式,请打开IIS并选择应用程序池.我被命名为"ASP.NET v4.0".
右键单击,转到"高级设置",将名为"启用32位应用程序"的部分更改为true.

重新启动Web服务器,然后重试.

我从这个博客参考中找到了修复:http: //darrell.mozingo.net/2009/01/17/running-iis-7-in-32-bit-mode/

此外,您可以更改Visual Studio上的设置.在我的情况下,我去了Tools > Options > Projects and Solutions > Web Projects并检查Use the 64 bit version of IIS Express for web sites and projects- 这是在VS Pro 2015上.除此之外没有其他任何修复.

  • 这很有帮助. (5认同)

woo*_*ony 5

我使用正确的框架安装了相同的异常.

我的解决方案是以管理员身份运行cmd ....然后它工作正常.

  • 这有点老......但是在Woony的辩护中...... 9个月之后,这就解决了我的问题. (3认同)
  • @RubenBartelink,如果Woony有一个解决方法,帮助他,分享是好的,即使他无法解释原因.这不是投票的理由,特别是在有其他高投票的答案时 (2认同)