.net MSB3270:处理器架构不匹配 - Fakes Framework
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18833006/
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
MSB3270: Mismatch between the processor architecture - Fakes Framework
提问by Snowcrack
Since I use Fakes Framework in my UnitTest, I get the following MSBuild warning.
由于我在 UnitTest 中使用 Fakes Framework,因此我收到以下 MSBuild 警告。
warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "DocumentServiceModel", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\Projekte\XXX\XXX\XXX\Source\Testing\UT\XXX.UnitTest\obj\Debug\Fakes\ppsm\f.csproj]
警告 MSB3270:正在构建的项目“MSIL”的处理器体系结构与参考“DocumentServiceModel”、“x86”的处理器体系结构之间存在不匹配。这种不匹配可能会导致运行时失败。请考虑通过配置管理器更改项目的目标处理器架构,以便在您的项目和参考之间对齐处理器架构,或者依赖于具有匹配项目目标处理器架构的处理器架构的参考。[C:\Projekte\XXX\XXX\XXX\Source\Testing\UT\XXX.UnitTest\obj\Debug\Fakes\ppsm\f.csproj]
The platform target of all projects in the solution is set to x86.
解决方案中所有项目的平台目标都设置为 x86。
How can I get rid of this build warning?
我怎样才能摆脱这个构建警告?
UPDATE1:
更新1:
I think the problem is, that the Fakes Framework creates a dynamic projekt with a platform target "Any CPU".
我认为问题在于,Fakes 框架创建了一个动态项目,其平台目标为“任何 CPU”。
(C:\Projekte\XXX\XXX\XXX\Source\Testing\UT\XXX.UnitTest\obj\Debug\Fakes\ppsm\f.csproj)
(C:\Projekte\XXX\XXX\XXX\Source\Testing\UT\XXX.UnitTest\obj\Debug\Fakes\ppsm\f.csproj)
This dynamic project references the assemblies from my projekt, which runs with a platform target "x86".
这个动态项目引用了我的项目中的程序集,它以平台目标“x86”运行。
I have no idea, how to change the dynamic Fakes projekt to "x86".
我不知道如何将动态 Fakes 项目更改为“x86”。
UPDATE2:
更新2:
I created a sample project and I get the same warning:
我创建了一个示例项目,但收到了相同的警告:
Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "MSBErrorTest", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. [C:\Projekte\MSBErrorTest\UnitTestProject1\obj\Debug\Fakes\msbet\f.csproj] UnitTestProject1
UnitTest csproj:
单元测试 csproj:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4B14EC56-DDC7-4A16-92BA-2D2881E695D1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTestProject1</RootNamespace>
<AssemblyName>UnitTestProject1</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="MSBErrorTest.Fakes">
<HintPath>FakesAssemblies\MSBErrorTest.Fakes.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MSBErrorTest\MSBErrorTest.csproj">
<Project>{f1ae6c89-6f6a-404e-b9e2-10ee2f66942f}</Project>
<Name>MSBErrorTest</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Fakes Include="Fakes\MSBErrorTest.fakes" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
ClassLib csproj:
ClassLib csproj:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F1AE6C89-6F6A-404E-B9E2-10EE2F66942F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MSBErrorTest</RootNamespace>
<AssemblyName>MSBErrorTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
UPDATE3:
更新3:
I changed my config to look like this.
我改变了我的配置看起来像这样。
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
But I still get the warning
但我仍然收到警告
采纳答案by Snowcrack
I have got a response from Microsoft for this issue
我已收到 Microsoft 对此问题的回复
Visual Studio 2012:
视觉工作室 2012:
Create the following element in “Fakes\MSBErrorTestClass.fakes” file under 'Fakes' node:
在“Fakes”节点下的“Fakes\MSBErrorTestClass.fakes”文件中创建以下元素:
<Compilation>
<Property Name=”PlatformTarget”>x86</Property>
</Compilation>
Visual Studio 2013:
视觉工作室 2013:
This issue has been fixed in the latest release i.e. Visual Studio 2013
此问题已在最新版本中修复,即 Visual Studio 2013
回答by Daryl
Since I'm getting this error only for Fakes assemblies that I will only be running unit tests on, I decided to just ignore this error. This can be accomplished by adding this to your Fakes XML:
由于我仅针对仅在其上运行单元测试的 Fakes 程序集收到此错误,因此我决定忽略此错误。这可以通过将其添加到您的 Fakes XML 来实现:
<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
<Assembly Name="FakedAssemblyName.dll"/>
<Compilation>
<Property Name="ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch">None</Property>
</Compilation>
</Fakes>
回答by Eriawan Kusumawardhono
Did you use 3rd party libraries? If you use them, check them to see if they use the same x86 as the target processor. It is clear that the targeted processor should be the same for all of the references, not just the target of your project.
您是否使用了第 3 方库?如果您使用它们,请检查它们是否使用与目标处理器相同的 x86。很明显,所有引用的目标处理器都应该是相同的,而不仅仅是项目的目标。
UPDATE: Apparently this guy from Microsoft is experiencing this also. You can try to use his workaround:
更新:显然这个来自微软的人也遇到了这个问题。您可以尝试使用他的解决方法:
http://blogs.msdn.com/b/astebner/archive/2012/05/03/10300809.aspx
http://blogs.msdn.com/b/astebner/archive/2012/05/03/10300809.aspx
From the blog entry, do this: Search for this "PlatformTarget" in your csproj file, and edit it to match this:
从博客条目中,执行以下操作:在您的 csproj 文件中搜索此“ PlatformTarget”,并对其进行编辑以匹配以下内容:
<PlatformTarget Condition=" '$(PlatformTarget)' == '' ">x86</PlatformTarget>
Let me know if this solve your problem.
如果这能解决您的问题,请告诉我。
UPDATE 2: Based on your source code of the unittest.csproj and the classlib.csproj, the configuration is still based on "AnyCPU".
更新 2:根据您的 unittest.csproj 和 classlib.csproj 的源代码,配置仍然基于“AnyCPU”。
Please look for this line:
请寻找这一行:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
And also this line:
还有这一行:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Those target platform should also be set to use x86.
那些目标平台也应该设置为使用 x86。
The easier way is by setting the Debug and Release by clicking "Configuration Manager..." at "Debug" combobox on Visual Studio toolbar, like in this rough illustration:
更简单的方法是通过单击 Visual Studio 工具栏上“调试”组合框中的“配置管理器...”来设置调试和发布,如下图所示:


回答by mazury
In project_name.csproj file remove ItemGroupnode where is set processorArchitecture attribute. It sth like;
在project_name.csproj 文件中删除ItemGroup设置 processorArchitecture 属性的节点。它……喜欢;
<ItemGroup>
<Reference ... , processorArchitecture=MSIL">
...
</ItemGroup>
<ItemGroup>
<Reference ... , processorArchitecture=MSIL">
...
</ItemGroup>
That helped for me.
那对我有帮助。
回答by Fandango68
For anyone that landed here and has nothing to do with "Fakes", check for warnings / errors in your References. I found a ghostDLL that fortunately the project did not require, and removed it. Worked great!
对于登陆这里并且与“假货”无关的任何人,请检查您的参考资料中的警告/错误。我发现了一个幽灵DLL,幸运的是该项目不需要,并将其删除。工作得很好!

