相关疑难解决方法(0)

BadImageFormatException故障排除

我有一个使用Visual Studio 2010用C#编写的Windows服务,目标是完整的.NET Framework 4.当我从Debug构建运行时,服务按预期运行.但是,当我从Release版本运行它时,我得到一个System.BadImageFormatException(详情如下).我一直在网上寻找解决方案,但到目前为止,我发现的每件事都没有帮助我找到解决方案.

Windows 7 64位(dev)和Windows XP SP3 32位(目标)系统都存在此问题.

这是我到目前为止所尝试的:

  • 已验证的构建设置(例如Platform Target)都是相同的(x86).
  • 使用带有/ verbose选项的peverify可确保程序集二进制文件有效.
  • 使用fuslogvw查找任何加载问题.
  • 使用CheckAsm查找丢失的文件或组件.

所有这些检查都没有改变任何东西.我已经在下面列出了例外信息的全文,其中一些名称已经更改,以保护我公司主人的秘密.

System.BadImageFormatException was unhandled
  Message=Could not load file or assembly 'XxxDevices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
  Source=XxxDevicesService
  FileName=XxxDevices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  FusionLog=Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable  c:\Dev\TeamE\bin\Release\XxxDevicesService.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = XXX
LOG: DisplayName …

.net c# exception

98
推荐指数
8
解决办法
17万
查看次数

标签 统计

.net ×1

c# ×1

exception ×1