MSB3270: Mismatch between the processor architecture - Fakes Framework

醉酒当歌 提交于 2019-11-30 04:39:28

I have got a response from Microsoft for this issue

http://connect.microsoft.com/VisualStudio/feedback/details/804933/msb3270-mismatch-between-the-processor-architecture-fakes-framework

Visual Studio 2012:

Create the following element in “Fakes\MSBErrorTestClass.fakes” file under 'Fakes' node:

<Compilation>
 <Property Name=”PlatformTarget”>x86</Property>
</Compilation>

Visual Studio 2013:

This issue has been fixed in the latest release i.e. Visual Studio 2013

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 xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="FakedAssemblyName.dll"/>
  <Compilation>
    <Property Name="ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch">None</Property>
  </Compilation>
</Fakes>

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.

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

From the blog entry, do this: Search for this "PlatformTarget" in your csproj file, and edit it to match this:

<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".

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.

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:

In project_name.csproj file remove ItemGroup node where is set processorArchitecture attribute. It sth like;

<ItemGroup> <Reference ... , processorArchitecture=MSIL"> ... </ItemGroup>

That helped for me.

For anyone that landed here and has nothing to do with "Fakes", check for warnings / errors in your References. I found a ghost DLL that fortunately the project did not require, and removed it. Worked great!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!