CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

MSB3271 mismatch between processor architecture when building projection

Open angelazhangmsft opened this issue 3 years ago • 0 comments

Describe the bug

An MSB3271 error/warning results when building a projection for AnyCPU while referencing a native C++/WinRT component.

Error message: Error MSB3271 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture, "x86", of the implementation file "C:\Users\angzhang\repos\CsWinRT\src\Samples\NetProjectionSample_build\Win32\Release\SimpleMathComponent\bin\SimpleMathComponent\SimpleMathComponent.dll" for "C:\Users\angzhang\repos\CsWinRT\src\Samples\NetProjectionSample_build\Win32\Release\SimpleMathComponent\bin\SimpleMathComponent\SimpleMathComponent.winmd". 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 implementation file, or choose a winmd file with an implementation file that has a processor architecture which matches the targeted processor architecture of your project.

To Reproduce

See the NetProjectionSample.

Version Info

CsWinRT 1.4.1, .NET 6

Workaround Add the following property to the library project:

<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>

angelazhangmsft avatar Feb 02 '22 00:02 angelazhangmsft