我似乎遇到了一个场景,当我在引用x64程序集的AnyCPU程序集上运行mstest时,我得到一个BadImageFormatException.
当AnyCPUTestingx64Production.dll测试程序集实现x64Production.dll中的接口(即使未使用)时,会出现此问题:
Unable to load the test container 'D:\AnyCPUTestingx64Production.dll'
or one of its dependencies. error details:
System.BadImageFormatException:
Could not load file or assembly 'x64Production, 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.
Run Code Online (Sandbox Code Playgroud)
- mstest在Windows 7 64位上运行
- 测试组件建成AnyCPU得到它在64位主机上运行64位(如概述这里)
- testsettings文件指定<Execution hostProcessPlatform ="MSIL"/>
- peverify和corflags没有任何有趣的东西
- 这在玩具解决方案中很容易重现,即在哪里
- x64Production
- 没有引用其他组件
- 仅包含一个空的公共接口IExampleInterface
- 将<PlatformTarget>设置为x64
- AnyCPUTestingx64Production
- 仅引用x64Production.dll(即使没有对Microsoft.VisualStudio.QualityTools.UnitTestFramework的引用,也会出现此问题)
- 仅包含x64Production.IExampleInterface的空实现
- 将<PlatformTarget>设置为x64
- nunit可以加载并运行测试程序集(一旦我转换了所有的测试属性)
- 但对于较大的问题(涉及大量项目文件)来说,这不是一个很好的短期解决方案
- 无论项目是3.5还是4.0,都会出现同样的问题
- 无论是使用VS2008还是VS2010 c#编译器,都会出现同样的问题
- 无论是使用VS2010的mstest还是使用测试代理,都会出现同样的问题
- 加载AnyCPUTestingx64Production时mstest失败 - 即尝试在错误的QTAgent中加载程序集时没有问题(进程监视器中没有显示任何内容,重命名QTAgent32.exe没有效果):
*** Assembly Binder Log Entry (09/02/2012 @ 09:44:26) …
Run Code Online (Sandbox Code Playgroud)