Looks like there are many similar problems without good explanation.
Environment:
Win 7
VS2012 Pro
Windows SDK 7.0
In our environment we generate 2 code bases - x86 and x64. For this specific project we generate *.XMlSerializers.dll
. The setting in the build for Generate Serialization Assemblies is Auto
.
When I compile project to x64 config, I get SGEN error "attempt load assembly in incorrect format... system.data.dll". This error is totally misleading because farther investigation brought the following results:
I used procmon
from sysinternals
to trace SGEN
- When building for AnyCpu and x86 procmon shows a trace. The sgen in use is from
C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin
(32-bit sngen.exe) - When building for x64 there is no trace and only error mentioned above
I set project configuration to create serializers to OFF and compiled assembly in x64. Then I tried a command line
- Success came about using SGEN in
C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\x64
- (please note - this is 64-bit sgen.exe) - Running 32-bit SGEN on x64 Assembly failed.
These results lead to a conclusion: When VS2012 compiles a project with Generate Serialization Assemblies set to ON (auto is a special case), it attempts to find sgen.exe. But when your project configuration is set to build for x64 platform, it fails to find appropriate sgen.exe, one that itself was built for x64.
Question: Is there msbuild configuration or registry setting, or something else there, that can be set to allow Visual Studio find appropriate SGEN?
I know about workarounds, i.e. Post Build events and turning it off but this is not the point.