我如何单元测试在x64平台上运行 [英] How do I get unit tests to run on a x64 platform

查看:129
本文介绍了我如何单元测试在x64平台上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序必须在64位模式下运行。问题是我尝试创建运行在64位应用程序和单元测试项目甚至不会建造方法的单元测试。我收到以下错误,当它试图打造。

I have a C# application that must run in x64 mode. The problem is I try to create unit tests that run methods in the x64 application and the unit test project won't even build. I get the following error when it tries to build.

错误加载C:..... \ BIN \ 64 \调试.... UnitTests.dll:无法加载测试容器'C:..... \ BIN \ 64 \调试.... UnitTests.dll或它的某一个依赖。如果你建立你的测试项目组装为一个64位汇编,它不能被加载。当你建立你的测试项目装配中,选择平台任何CPU。要在64位处理器上运行的测试,在64位模式,则必须更改主机选项卡测试设置在一个32位进程运行测试。错误信息:未能加载文件或程序集文件:/// C:.....单元测试\ BIN \ 64 \调试.... UnitTests.dll或它的某一个依赖。试图用不正确的格式加载程序。

Error loading C:.....\bin\x64\Debug....UnitTests.dll: Unable to load the test container 'C:.....\bin\x64\Debug....UnitTests.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///C:.....UnitTests\bin\x64\Debug....UnitTests.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

我试图改变单元测试到x64以及任何CPU,仍然无法得到它运行。是否有修复此?

I have tried to change the unit test to x64 and also Any CPU and still cannot get it to run. Is there any fix for this?

推荐答案

我假设你正在使用的Visual Studios的测试框架,因为你提到,没有其他。 在VS2010您可以强制检测主机在64位运行。 建立你的组件作为任何CPU或x64然后将测试主机到x64。

I'm assuming that you are using Visual Studios testing framework since you mention no other. In VS2010 you can force the testing host to run in x64. Build your assemblies as Any CPU or x64 then set the test host to x64.

<一个href="http://msdn.microsoft.com/en-us/library/ee782531.aspx">http://msdn.microsoft.com/en-us/library/ee782531.aspx

这篇关于我如何单元测试在x64平台上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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