将 Visual Studio C# 项目从 x86 更改为 Any CPU

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2147737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:54:46  来源:igfitidea点击:

Changing a Visual Studio C# project from x86 to Any CPU

c#visual-studio-2005

提问by WildCrustacean

I am working on some C# projects with Visual Studio 2005, and I am trying to change the platform target from x86 to Any CPU. I already went through all the dependencies that I know about and made sure that they were also built for Any CPU using the corflags tool.

我正在使用 Visual Studio 2005 处理一些 C# 项目,并且我正在尝试将平台目标从 x86 更改为 Any CPU。我已经了解了我所知道的所有依赖项,并确保它们也是使用 corflags 工具为 Any CPU 构建的。

When I change the platform target in Visual Studio 2005 it seems like it saves the change, but then when I build the project it still uses x86 anyway. The next time I open the project the platform target has been reset to x86.

当我在 Visual Studio 2005 中更改平台目标时,它似乎保存了更改,但是当我构建项目时,它仍然使用 x86。下次打开项目时,平台目标已重置为 x86。

This only happens for a couple of the projects in the solution, does this mean that there are other 32-bit dependencies somewhere?

这只发生在解决方案中的几个项目中,这是否意味着在某处还有其他 32 位依赖项?

I can manually run the C# compiler on the command line with /platform:anycpuand I don't get an error, but I'm not sure that is the right thing to do and I'd like to be able to build within Visual Studio.

我可以在命令行上手动运行 C# 编译器,/platform:anycpu并且没有出现错误,但我不确定这样做是否正确,我希望能够在 Visual Studio 中进行构建。

What can I do to solve this problem?

我能做些什么来解决这个问题?

采纳答案by user7116

Make sure you've changed both the Configuration Platformand the Platform Targetto Any CPU. If all else fails you can open up the .csprojand manually change the references. Right click on the Project, goto Unload Project. Then right click and goto Edit MyProject.csproj. The properties for the project may still include the default Platform as x86:

确保您已将配置平台平台目标都更改为Any CPU. 如果所有其他方法都失败了,您可以打开.csproj并手动更改引用。右键单击项目,转到卸载项目。然后右键单击并转到Edit MyProject.csproj。项目的属性可能仍包括默认平台为 x86:

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>

Also consider the case where the Solution still has the x86 configuration in Configuration Manager. I've found for some complex Solutions with multiple projects that have different configurations I have to spend a lot of time in Configuration Manager getting everything straight.

还要考虑解决方案在 Configuration Manager 中仍然具有 x86 配置的情况。我发现对于一些具有不同配置的多个项目的复杂解决方案,我必须在配置管理器中花费大量时间来解决所有问题。