NUnit 项目引起的 System.BadImageFormatException [英] System.BadImageFormatException caused by NUnit project

查看:26
本文介绍了NUnit 项目引起的 System.BadImageFormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我一整天都在工作中遇到同样的问题,并且正在努力寻找任何新的路径.

Good day everyone. I have been having the same problem all day at work and am struggling to find any new paths to go down.

当我的解决方案在服务器上构建时出现以下错误.我在解决方案中运行/调试所有测试都没有问题,并且它构建得很好.服务器和我的电脑都是 x64.我遵循了很多建议,但发现都无济于事.

I am getting the following error when my solution builds on server. I have no problem running/debugging all tests in the solution and it builds fine. Both server and my PC are x64. I have followed a lot of advice which I have found to no avail.

我已在所有配置下将解决方案中的所有项目的平台目标设置为 x86.

I have set Platform Target to x86 for all projects in my solution under all configurations.

我知道有一个 nunit-console-x86.exe 可以发挥所有作用,但我不确定在代码中的何处指定它.

I am aware that there is an nunit-console-x86.exe which could make all the difference but I'm not sure where to specify this in the code.

请注意我已经在互联网上开辟了道路,如果我错过了什么,请见谅.

Please realise I have trail-blazed the internet, so apologies if I have missed something.

System.BadImageFormatException:无法加载文件或程序集
'Spin.TradingServices.DataAcquisition.Test.NUnit,版本=1.0.12103.2060,文化=中性,PublicKeyToken=null'或一它的依赖关系.试图加载一个程序格式不正确.
文档名称:'Spin.TradingServices.DataAcquisition.Test.NUnit,版本=1.0.12103.2060,文化=中性,PublicKeyToken=null'

System.BadImageFormatException: Could not load file or assembly
'Spin.TradingServices.DataAcquisition.Test.NUnit, Version=1.0.12103.2060, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'Spin.TradingServices.DataAcquisition.Test.NUnit, Version=1.0.12103.2060, Culture=neutral, PublicKeyToken=null'

服务器堆栈跟踪:在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssemblylocationHint、StackCrawlMark&stackMark,布尔 throwOnFileNotFound,布尔用于内省,布尔抑制安全检查)在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyNameassemblyRef、证据程序集安全性、StackCrawlMark&堆栈标记,布尔用于内省,布尔抑制安全检查)在 System.Reflection.Assembly.Load(AssemblyName assemblyRef)在 NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)在 NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)在 NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)在 NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage 包)在 NUnit.Core.TestSuiteBuilder.Build(TestPackage 包)在 NUnit.Core.SimpleTestRunner.Load(TestPackage 包)在 NUnit.Core.ProxyTestRunner.Load(TestPackage 包)在 NUnit.Core.ProxyTestRunner.Load(TestPackage 包)在 NUnit.Core.RemoteTestRunner.Load(TestPackage 包)在 System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtrmd, Object[] args, 对象服务器, Int32 methodPtr, BooleanfExecuteInContext, Object[]&outArgs)在 System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessagemsg, Int32 methodPtr, Boolean fExecuteInContext)

Server stack trace: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path) at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites) at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites) at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package) at NUnit.Core.TestSuiteBuilder.Build(TestPackage package) at NUnit.Core.SimpleTestRunner.Load(TestPackage package) at NUnit.Core.ProxyTestRunner.Load(TestPackage package) at NUnit.Core.ProxyTestRunner.Load(TestPackage package) at NUnit.Core.RemoteTestRunner.Load(TestPackage package) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessagereqMsg, IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32 类型)在 NUnit.Core.TestRunner.Load(TestPackage 包)在 NUnit.Util.TestDomain.Load(TestPackage 包)在 NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions 选项)在 NUnit.ConsoleRunner.Runner.Main(String[] args)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at NUnit.Core.TestRunner.Load(TestPackage package) at NUnit.Util.TestDomain.Load(TestPackage package) at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options) at NUnit.ConsoleRunner.Runner.Main(String[] args)

警告:程序集绑定日志已关闭.要启用程序集绑定失败日志记录,请设置注册表值[HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) 为 1.注意:有是与程序集绑定失败相关的一些性能损失日志记录.要关闭此功能,请删除注册表值[HKLMSoftwareMicrosoftFusion!EnableLog].

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].

http://app1017-build.oy.gb.sportingindex.com:8080/job/TradingServices.DataAcquisition-Dev/ws/DataAcquisition/build.proj(86,5):错误 MSB6006:nunit-console.exe"以代码 -100 退出.完毕建筑工程"(默认目标)--失败.

http://app1017-build.oy.gb.sportingindex.com:8080/job/TradingServices.DataAcquisition-Dev/ws/DataAcquisition/build.proj(86,5): error MSB6006: "nunit-console.exe" exited with code -100. Done Building Project " (default targets) -- FAILED.

构建失败.

请注意:我们已经恢复了我们在 Hudson 上的构建,现在更加缓慢地重新提交文件.我将报告情况如何.不幸的是,尝试让几个人参与其中但无济于事.耻辱!

PLEASE NOTE: We have reverted our build on Hudson and now re-committing files more gradually. I will report back on how this goes. Tried get a few heads involved on this one to no avail unfortunately. Shame!

更新我有一段时间没有回到这个页面,但看起来有很多不同的解决方案.如果我可以将它们全部标记为答案,我会!那些在这里找到自己方式的人可能应该对每个选项给予同等的信任.

Update I haven't been back to this page for a while but it looks like there are lots of different solutions. If I could mark them all as the answer I would! Those of you finding your way here should probably give equal credit to each option.

推荐答案

检查程序集的目标框架版本是否与 nUnit 测试运行程序支持的相同.有关支持的运行时列表,请参阅 runFile.exe.config.

Check the target framework version of your assembly are same as nUnit test runner supports. See runFile.exe.config for list of supported runtimes.

此外,如果您从 FW 3 迁移到 FW 4,它们的运行时间不同(CLR 不同).

Also if you have megrated from FW 3 to FW 4, they has different runtime (CLR is different).

这篇关于NUnit 项目引起的 System.BadImageFormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆