c# - 如何让单元测试在 x64 平台上运行

标签 c# .net asp.net visual-studio

我有一个必须在 x64 模式下运行的 C# 应用程序。问题是我尝试创建在 x64 应用程序中运行方法的单元测试,但单元测试项目甚至无法构建。尝试构建时出现以下错误。

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,但仍然无法运行。有什么解决办法吗?

最佳答案

在 VS 2012 及更高版本中,您可以从 Test Settings|Default Processor Architecture 下的 Test 菜单中选择默认目标平台

Visual Studio Test Settings

关于c# - 如何让单元测试在 x64 平台上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5571699/

相关文章:

c# - 为 Abp 用户角色禁用软删除

c# - 同时读取和写入数据到文件

c# - 通用属性的序列化

c# - WCF 服务调用包装器

c# - WCF 模拟不是模拟管理员

c# - Service-Fabric 绑定(bind)到多个端点

c# - 查找复选框的值

asp.net - 手动升级后将新的 ASP.NET Web 优化框架添加到 MVC4 项目

asp.net - 无法运行空的 ASP.Net MVC 3 应用程序

asp.net - 可能在 ASP.Net 页面中抛出 404 错误?