2

I know this is a common error for people compiling with mismatched project settings, and I've looked through a lot of those questions and answers. However, I don't appear to have mismatched project settings.

I've recently "inherited" a C# codebase that came with about 250 compile warnings. I've gotten rid of all the others, but I can't figure out how to get rid of this one:

2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:{my DLL project path}{my lib}.dll", "AMD64". 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.

Both projects are built using the "Developer" and "x64" configurations/platform combo. When I look in the Configuration Manager, both projects are showing that same configuration and platform. I went and checked their .csproj files, and the section for that config for both is identical:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Development|x64'">
    <DebugSymbols>true</DebugSymbols>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <DebugType>full</DebugType>
    <ErrorReport>prompt</ErrorReport>
    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

So where's the mismatch? How do I fix this?

T.E.D.
  • 44,016
  • 10
  • 73
  • 134
  • Double-check that all your projects in your solution is x64, since clearly the compiler thinks at least one project is "Any CPU" (MSIL). – Lasse V. Karlsen Jul 17 '20 at 21:47
  • @LasseV.Karlsen - All of them *have* that config/platform combination. There is one C++ project, but it also has that configuration, and according to the Config Manager is not checked to be built. What makes VS decide that's the platform? Is it just the string in $(Platform), or is it calculating it somehow? – T.E.D. Jul 17 '20 at 22:03
  • ... To clarify, in the Config Manager gui, every Platform reads "x64", and "Any CPU" isn't an option in the drop-down for any of them. – T.E.D. Jul 17 '20 at 22:09
  • Have you checked the project properties to ensure they reflect what is in the configuration manager? – David.Warwick Jul 17 '20 at 22:22
  • @David.Warwick - They all say "x64" on the dropdown next to "Platform target:" on the Build tab, if that's what you mean. (other than the C++ project of course). – T.E.D. Jul 17 '20 at 22:27
  • If you use some PowerShell scripts to dump `ProcessorArchitecture` field of all assemblies involved (yours as well as dependencies) like https://stackoverflow.com/questions/270531/how-can-i-determine-if-a-net-assembly-was-built-for-x86-or-x64, you should be able to observe inconsistency that triggers the MSBuild warnings. However, if your project runs successfully, you can ignore such most of the time. – Lex Li Jul 17 '20 at 23:00
  • 1
    According to your question, you can try adding the following to the .csproj file. None If it's not solved, you can refer to this website: [How do I fix the Visual Studio compile error, “mismatch between processor architecture”?](https://stackoverflow.com/questions/10113532/how-do-i-fix-the-visual-studio-compile-error-mismatch-between-processor-archit/12672514#12672514), hoping to help you. – Jack J Jun Jul 20 '20 at 07:13
  • @LexLi - Well, that shows pretty much what the warning said I guess: the DLL in question has a ProcessorArchitecture of "Amd64". Which is fine, and what I'm trying to do. I guess the mysterious part is why it thinks the project exe being built isn't also AMD64. – T.E.D. Jul 20 '20 at 12:51
  • 1
    @JackJJun-MSFT - Thanks for the tip. Of course ignoring the warning isn't fixing the warning, but unless/until I can at least figure out why its happening, that works. – T.E.D. Jul 20 '20 at 21:29

0 Answers0