Visual Studio 2012 adds reference to wrong DLL RRS feed

  • Question

  • I was having trouble getting Visual Studio 2012 to build my project in release mode... it gave me errors about assemblies being the wrong format. Turns out some x86 assemblies were being referenced instead of x64 assemblies. Assemblies like PresentationCore, System.Data and so on.

    Things I tried:

    • Debug mode, any CPU builds fine.

    • Debug mode, x64 builds fine.

    • Release mode, any CPU fails

    • Release mode, x64 fails (this is the combination I'd LIKE to build my project in)

    The issue comes when I try to remove the x86 reference and switch it to a x64 reference. Visual studio just adds the old x86 reference instead of the x64 reference. For example:

    I remove the System.Data reference which is inC:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll

    I browse to and add C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Data.dll, but when I click on that System.Data reference, the path is CLEARLY still to the old dll and causes the same error to occur. This is happening with several other DLLs as well.

    Since I couldn't get Visual Studio to add the reference to the correct DLL, I started poking around for another solution. Oddly, turning "Generate serialization assembly" off under Build in project properties makes the project build just fine in release mode. Looking at this link reveals that this setting has to do with XML Serialization, which we don't even use in our entire solution.

    Does anyone have any explanation/fix for any of the issues I've run into here? I have everything working now, but I'd still like to understand why this change "fixed" my issue and if the DLL adding thing is, in fact, a bug.

    Thursday, November 29, 2012 3:37 PM