如何解决Visual Studio的编译错误,"处理器架构&QUOT之间的不匹配;? [英] How do I fix the Visual Studio compile error, "mismatch between processor architecture"?

查看:1316
本文介绍了如何解决Visual Studio的编译错误,"处理器架构&QUOT之间的不匹配;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的项目在Visual Studio 2010中的配置,但我已经做了一些<一href="http://visualstudiohacks.com/articles/visual-studio-net-platform-target-explained/">research仍不能完全弄清楚这个问题了。我有一个Visual Studio解决方案用C ++ DLL引用C#DLL。 C#的DLL引用了一些其他的DLL,我的一些项目和一些外部之内。当我尝试编译C ++ DLL,我得到这样的警告:

I'm new to project configuration in Visual Studio 2010, but I've done some research and still can't quite figure this issue out. I have a Visual Studio solution with a C++ DLL referencing the C# DLL. The C# DLL references a few other DLLs, some within my project and some external. When I try to compile the C++ DLL, I get this warning:

警告MSB3270:有项目存在建设MSIL的处理器架构和参考内部C#DLL]的处理器架构之间的不匹配,86

warning MSB3270: There was a mismatch between the processor architecture of the project being build "MSIL" and the processor architecture of the reference "[internal C# dll]", "x86".

它告诉我去配置管理器来调整我的架构。 C#的DLL是设置了目标平台的x86。如果我试图改变这个别的东西,像任何CPU,它抱怨因为外部的DLL之一的的依赖于有平台的目标86。

It tells me to go to Configuration Manager to align my architectures. The C# DLL is set up with platform target x86. If I try to change this to something else, like Any CPU, it complains because one of the external DLLs it depends on has platform target x86.

当我在看配置管理器它显示了我的C#DLL的x86和对我的C ++项目是Win32平台。这似乎是正确的设置;当然我不希望这个项目对我的C ++的项目有平台设置为64位,这是唯一的选择presented。

When I look at Configuration Manager it shows the Platform for my C# DLL as x86 and for my C++ project as Win32. This seems like the right setup; surely I don't want the project for my C++ project to have platform set to x64, which is the only other option presented.

我在做什么错在这里?

推荐答案

这个警告似乎已经推出了新的Visual Studio 11 Beta版和.NET 4.5,但我想它可能之前都没有可能。

This warning seems to have been introduced with the new Visual Studio 11 Beta and .NET 4.5, although I suppose it might have been possible before.

首先,这真的只是一个警告。它不应该伤害任何东西,如果你只是处理的x86依赖性。微软只是想,当你指出你的项目是任何CPU兼容提醒你,但你必须在一个项目或.dll组件,它是x86或x64的依赖。因为你有一个x86的依赖,在技术上你的项目,因此不是任何CPU兼容。为了使警告消失,其实你应该你的项目从任何CPU到86改变。这是很容易做到的,这里的步骤。

First, it really is just a warning. It should not hurt anything if you are just dealing with x86 dependencies. Microsoft is just trying to warn you when you state that your project is compatible with "Any CPU" but you have a dependency on a project or .dll assembly that is either x86 or x64. Because you have an x86 dependency, technically your project is therefore not "Any CPU" compatible. To make the warning go away, you should actually change your project from "Any CPU" to "x86". This is very easy to do, here are the steps.

  1. 转到构建|。配置管理器菜单项
  2. 找到列表中的项目,平台下它会说任何CPU
  3. 下来从下拉的任何CPU选项,然后选择&LT;新..&GT;
  4. 从该对话框中,从新平台选择86下拉,并确保任何CPU是在复制设置从下拉选择。
  5. 点击确定
  6. 您将要选择的x86为调试和发布配置。
  1. Go to the Build|Configuration Manager menu item.
  2. Find your project in the list, under Platform it will say "Any CPU"
  3. Select the "Any CPU" option from the drop down and then select <New..>
  4. From that dialog, select x86 from the "New Platform" drop down and make sure "Any CPU" is selected in the "Copy settings from" drop down.
  5. Hit OK
  6. You will want to select x86 for both the Debug and Release configurations.

这将使警告消失,并指出,你的程序集或项目现在不再是任何CPU兼容,但现在的x86特有的。这也适用,如果你正在建设一个64位的项目中,有一个64位的依赖;你只需选择64来代替。

This will make the warning go away and also state that your assembly or project is now no longer "Any CPU" compatible but now x86 specific. This is also applicable if you are building a 64 bit project that has an x64 dependency; you would just select x64 instead.

另外一个说明,项目可以是任何CPU兼容通常,如果他们是纯粹的.NET项目。此问题仅出现如果引入的依赖(第三方DLL或您自己的C ++托管项目)是针对特定处理器架构。

One other note, projects can be "Any CPU" compatible usually if they are pure .NET projects. This issue only comes up if you introduce a dependency (3rd party dll or your own C++ managed project) that targets a specific processor architecture.

希望这有助于。

这篇关于如何解决Visual Studio的编译错误,&QUOT;处理器架构&QUOT之间的不匹配;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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