On a 64-bit system, set up a compilation platform for x86 projects compiled in a specific case, such as when a form is placed with an image ImageList, ResGen will have this problem
Compiling is normal when there is no image in this ImageList, but it can be thrown when compiled.
The reason for this error is that the compilers used internally by VS2010, whether 32-bit or 64-bit compiled components, are pure IL, that is, running in 64-bit mode on 64-bit systems, regardless of the platform settings used by the current project. When a compiled component references a library labeled x86 (32-bit mode only), the compilation component will fail with an error and cannot be loaded, resulting in a compilation failure.
This problem occurs in the following situations :
1, use any version of MSBuild on a 64-bit operating system to compile a. Net 3.5 project that references only 32-bit components;
2, a project that references only 32-bit components using 64-bit MSBuild compilation;
3, a project that references only 64-bit components is compiled with 32-bit MSBuild.
To solve this problem, you can set all of the library's target platforms to anycpu in the solution manager.
If the final execution platform is required X86 simply set the final execution file target platform to x86:
This compiles correctly.
The platform that the program eventually runs is based on the settings of the executable file, so setting the anycpu in the library does not affect the running of the final program, and the operation remains under x86.
However, if the referenced DLL has only 32 bits, then this method will not work, the workaround http://support.microsoft.com/kb/2028833, see MSBuild 4.0 or Visual Studio Compile a 32-bit application targeted for. Net Framework 3.5, 3.0 or 2.0 on x64 machine.
Detailed steps to resolve are as follows:
1. Close all visual Studio;
2, as an administrator to open the VS2010 Command Prompt window;
3. Change the catalogue to "<system_drive>:\program Files (x86) \microsoft sdks\windows\v<x.xx>\bin\" below;
4, enter the command corflags/32bit+ Resgen.exe/force, execute;
5. Open the <project_name>.csproj file using Notepad;
6, add <resgentoolarchitecture>managed32bit</resgentoolarchitecture> under PropertyGroup, save, close exit.
Now re-open the original project in VS2010, compile and pass, can run correctly!
The reason that the step can be run is that the ResGen is running in 32-bit mode instead of 64 bits, so it can load an assembly labeled 32-bit only. The price is-it can no longer compile an assembly marked as a 64-bit pattern.
For this issue, there is another workaround, open the Project Properties page, select the Applications tab, set the target framework for the. NET Framework 4. (This is not tested due to frame limitations)
For more information about the CorFlags.exe conversion tool, see http://msdn.microsoft.com/zh-cn/library/ms164699.aspx
For more information about the Resgen.exe resource File generator, see http://msdn.microsoft.com/zh-cn/library/ccec7sz1.aspx
Reference Garden article http://www.cnblogs.com/nicch/archive/2010/05/25/building_cross_platform_application_on_64bit_msbuild.html
Http://www.cnblogs.com/hans_gis/archive/2011/07/22/2114013.html
On a 64-bit system, set up a compilation platform for x86 projects compiled in a specific case, such as when a form is placed with an image ImageList, ResGen will have this problem