locked
Mismatch betweens processor achitecture RRS feed

  • Question

  • hi.

    I have a vs 2010 solution with managed code, managed c++ and native code. it contains one .exe (managed code), everything else is building dlls. we have two setups: one, where the .exe gets build for x86, the other where it gets build for x64. in setup one, the native projects build 32bit code, in the other, the native projects produce 64bit code. all the managed projects simply build msil. this results in two versions of the product, where one is 64bit, the other is 32bit.

    Now, just recently, i installed vs 2012 and .net 4.5. (i'm still using vs2010 because of the xp issue with the c++ compiler.). Ever since, i receive the following warning:

    ==============

    Warning 150 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Statik\kernel\lib\Debug\kernel.native.calculations.aussteifung.dll", "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. xaus.implementation

    ========

    (i see like 60 or so of these warnings, and the Error List isn't actually useable anymore.). i understand what the warning is trying to tell me - but in my setup the point it's trying to make simply isn't a problem.

    How do i get rid of these warnings?

    WM_THXADVANCE
    -thomas woelfer


    http://www.die.de/blog

    Friday, September 21, 2012 10:56 AM

Answers

  • If the managed projects rely on an x86 vs x64 native component then you do need to change the configuration appropriately.  Using Configuration Manager it is really quick and easy to fix things up.  This ensures everything builds correctly.

    If you don't want to go through that and you are confident your builds are going to be right then you can ignore the error.  You can't disable that particular warning AFAIK because it isn't coming from the compiler.  If there is a CS error code then you could specify to ignore it in the project settings but you're still going to have to disable it in every project.

    Michael Taylor - 9/24/2012
    http://msmvps.com/blogs/p3net

    • Marked as answer by thomas_woelfer Tuesday, September 25, 2012 5:44 PM
    Monday, September 24, 2012 4:45 PM
    Moderator
  • So you're getting this on C# projects but only in x64 builds.  I would recommend that you confirm that in the solution's Configuration Manager you are building for the x64 platform for all your projects.  I'd then open the project's property settings for the corresponding configuration/platform and ensure the Platform Target under Build is also x64.  They should almost always line up with the Configuration/Platform setting but you never know. 

    mscorlib is automatically included whenever you build managed code.  It is were the core .NET library is implemented and is required by all managed code.

    • Marked as answer by thomas_woelfer Tuesday, September 25, 2012 5:44 PM
    Tuesday, September 25, 2012 2:41 AM
    Moderator

All replies

  • You will get this message if you are compiling a project for AnyCPU but you have a reference to a platform-specific binary.  The warning is telling you that, while the project itself will be either x86 or x64 depending upon the runtime platform, it has a dependency on a binary that only works in x86 (or x64) mode so if you don't run it on the corresponding platform then the binary will fail at runtime.  In Windows x86 processses can only load x86 binaries and x64 processes can only load x64 binaries.  The warning says you're violating this rule.

    I don't fully understand your project layout but I'd say that you have a .NET assembly that is being compiled as AnyCPU but is referencing one of your native components being compiled as x86.  Note that if you are using project references then the target configuration/platform is determined by the solution-level Configuration Manager options.  If you're using binary references then the binary you're pointing to determines it. 

    For binary references VS doesn't support changing the targeted binary path based upon configuration so if you build your native components into different directories depending upon platform (a common scenario) then VS is going to get confused.  Some folks use envvars to work around it and, while it'll generally work, VS doesn't understand it so you'll get the warning anyway.

    Michael Taylor - 9/21/2012
    http://msmvps.com/blogs/p3net

    Friday, September 21, 2012 2:41 PM
    Moderator
  • Michael,

    i understand what the message is trying to tell me. Do i _really_ need to change all of the managed projects configurations so that they build for x86 in the x86 build and build for x64 in the x64 build, jus to get rid of that message? my project layout ensures that all the right binaries end up in the correct places (the .exe loading the managed assemblies will either be build for x86 or for x64, thus the managed dlls will automatically running in the correct bitnes.)

    if there was another way to turn off that warning (e.g.: via some configuration i'm not aware of), i'd really prefer to go that way instead of changing all of my projects.

    WM_THX
    -thomas

    http://www.die.de/blog

    Monday, September 24, 2012 3:30 PM
  • If the managed projects rely on an x86 vs x64 native component then you do need to change the configuration appropriately.  Using Configuration Manager it is really quick and easy to fix things up.  This ensures everything builds correctly.

    If you don't want to go through that and you are confident your builds are going to be right then you can ignore the error.  You can't disable that particular warning AFAIK because it isn't coming from the compiler.  If there is a CS error code then you could specify to ignore it in the project settings but you're still going to have to disable it in every project.

    Michael Taylor - 9/24/2012
    http://msmvps.com/blogs/p3net

    • Marked as answer by thomas_woelfer Tuesday, September 25, 2012 5:44 PM
    Monday, September 24, 2012 4:45 PM
    Moderator
  • Michael,

    well, i'm confident my builds are ok. (after all, i've been working on this project for the last 10+ years, and i've been shipping 32 and 64bit builds for several years.)

    however, i cannot 'ignore' the warning, because i see tons of them. so many, that it's impossible to use the error list anymore.

    Thus, 2 hours and several hundred mouseclicks later, i have changed all projects in the solution so the now longer build for "any cpu" but for either x86 or x64. The good thing is, the warning is now gone :-)

    the bad: now i get "Referenced assembly 'mscorlib.dll' targets a different processor. sigh. i see these on some of the c# projects, in the x64 build. Any suggestions how i might get rid of these? (Obviously, i have no references to the mscorlib binary in these projects. Infact, i haven't got any references to mscorlib at all, at least these are not visible in solution explorer.)

    WM_THXADVANCE
    -thomas woelfer


    http://www.die.de/blog

    Monday, September 24, 2012 7:21 PM
  • So you're getting this on C# projects but only in x64 builds.  I would recommend that you confirm that in the solution's Configuration Manager you are building for the x64 platform for all your projects.  I'd then open the project's property settings for the corresponding configuration/platform and ensure the Platform Target under Build is also x64.  They should almost always line up with the Configuration/Platform setting but you never know. 

    mscorlib is automatically included whenever you build managed code.  It is were the core .NET library is implemented and is required by all managed code.

    • Marked as answer by thomas_woelfer Tuesday, September 25, 2012 5:44 PM
    Tuesday, September 25, 2012 2:41 AM
    Moderator
  • Michael,

    i did not yet get to fix this, but i just found out that i only get this warning for some c# projects, but not others. Thus, i should be able to figure this out.

    WM_THX
    -thomas woelfer


    http://www.die.de/blog

    Tuesday, September 25, 2012 5:43 PM
  • Michael,

    well, looks like i'm _not_ able to figure this out. i don't seen any differences in project managed or in the projects properties, but still some give me "mscorlib target a different processor' and others don't.

    i turned on more detailed information and build one of the projects where i see this, and it looks like the 'interesting' part is this:

    ========

    Task "AL"

      C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\AL.exe /culture:en /out:obj\DebugX64\en\framework.resources.dll /platform:x64 /template:obj\DebugX64\framework.dll /embed:obj\DebugX64\framework.strings.en.resources

      Microsoft (R) Assembly Linker version 10.0.30319.1

      Copyright (C) Microsoft Corporation. All rights reserved.

     

    ALINK : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor

    Done executing task "AL".

    ========

    From the looks of it, this seems to have something to do with the "en" resources i'm putting into the lokalized resources assembly.

    Any suggestions where else to look ?

    WM_THX
    -thomas woelfer


    http://www.die.de/blog

    Thursday, September 27, 2012 2:07 PM
  • The assembly resource is being compiled as x64.  That would indicate you either selected the x64 platform or you're using AnyCPU and you're compiling on an x64 machine.  The localized assembly projects should be using the same platform settings as the class libraries.

    Michael Taylor - 9/27/2012
    http://msmvps.com/blogs/p3net

    Thursday, September 27, 2012 2:57 PM
    Moderator
  • Michael,

    yes indeed, this is "any cpu" on a 64bit machine. but how do i specify settings for the localized assembly? it's not like this is a different project - all i have are 2 resource files inside the project: one for german and one for english resources. the ide builds the en assembly automatically when it builds the main assembly. so how do i specify settings for that assembly ? (after all, there is only one set of settings for the project; at least i'm not aware of seperate settings for the en resource assembly...)

    WM_THX
    -thomas woelfer


    http://www.die.de/blog

    Friday, September 28, 2012 1:44 PM
  • Michael,

    some more info: it appears, visual studio will build the localized assemblies somewhat different then it builds the main assembly itself. as it does this fully automatically (one only needs to add a "filename.2LettersLangId.ext" file to the project and the "2LetterLangId" localized assembly gets build), i don't see how one could specify settings for the process of building this assembly.

    i consider this to be a bug in vs: it should not build the localized assembly with different settings than the main one.

    anyhow, i simply removed the very few localized resources (the product isn't really localized anyway), and the warnings are gone.

    WM_THX
    -thomas woelfer


    http://www.die.de/blog

    Friday, September 28, 2012 3:01 PM