Tag Archives: VS2010

x64 C# warning – Referenced assembly ‘System.Data.dll’ targets a different processor

Using Visual Studio 2010 C# to compile .NET project for Target Platform x64, the following two warnings appears:

------ Rebuild All started: Project: TestProject-64-bit, Configuration: Debug x64 ------
warning CS1607: Assembly generation -- Referenced assembly 'System.Data.dll' targets a different processor
warning CS1607: Assembly generation -- Referenced assembly 'mscorlib.dll' targets a different processor

Compile complete -- 0 errors, 2 warnings
Manager -> P:\Project Files\TestProject-64-bit\Test-x64.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

It is a bug in Visual Studio 2010, and warnings can be safely ignored. There are some bugs already filled in MS Connect. Suggestion is:
Edit the project file directly. Replace the references that are having this problem with explicit paths to the 64 bit ones, eg.,:
<Reference Include="$(Windir)\Microsoft.NET\Framework64\v2.0.50727\system.data.dll" />
<Reference Include="$(Windir)\Microsoft.NET\Framework64\v2.0.50727\mscorlib.dll"/>

Great suggestion, but it won’t work if you need to compile / build both for x86 and x64 platforms. And that is what I need.

MSDN Forum post suggests to disable warning:
Parameters Tab - Advanced - MSBuild Arguments, type /p:NoWarn=1607

It seems, that it is for Team Edition, it does not make sense for me, so I use:
Properties - Build - Suppress warnings: 1607

Currently must live with this hack, if you need to target both 32 and 64-bit platforms. Hope the fix will be released so we can remove warning suppression.

zlib 1.2.5 – fatal error LNK1120: X unresolved externals

When trying to link program to zlib 1.2.5 static library (zlib.lib), I got the following error:
fatal error LNK1120: X unresolved externals ...

Version 1.1.3 worked without any problems. Without going into details, here is what I did – using DUMPBIN.EXE I figured out that I am using __cdecl (/Gd) Calling convention, but zlib somehow overrides it with __stdcall (/Gz). Two hours letter I found that Visual Studio 2010 solution (zlib-1.2.5\contrib\vstudio\vc10\zlibvc.sln) has definition ZLIB_WINAPI.

Removing ZLIB_WINAPI solved my problem. To remove, it go to:
zlibstat Properties – Configuration Properties – C/C++ – Preprocessor – Preprocessor Definitions

Alternatively, you can comment out ifdef block – #ifdef ZLIB_WINAPI.

Remove .pdb path from exe in Microsoft Visual Studio 2010

If you look at executables shipped from Microsoft like notepad.exe, you will see that they include .pdb (Program Database) reference, but do not include path to .pdb:
notepad.pdbvs
d:\some\dir\release\bin\etc\notepad.pdb

This path can sometimes reveal unnecessary information to your customer / user, so if you want to get rid of that path in Visual Studio 2008, you could use undocumented switch:
/pdbpath:none

In Visual Studio 2010 (c++) you can use documented switch:
/PDBALTPATH:%_PDB%

Reference: Visual Studio 2010 – Visual C++ – /PDBALTPATH

Unfortunately, I can not find a such option for .net / C# executables. The only option it seems is /pdb switch, but it is not accessible from IDE.

P.S. To view .pdb reference within exe file, use Hex Editor or dumpbin utility
dumpbin /headers notepad.exe