When building ArcGIS Engine Controls-based applications on a supported 64-bit Operating System (OS) targeting the Microsoft .NET 3.5 framework in Visual Studio 2010, the following error may occur:"Could not load file or assembly 'file:///C:/Program Files (x86)/ArcGIS/DeveloperKit10.0/DotNet/ESRI.ArcGIS.3DAnalyst.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Line 162, position 5. C:\temp\Projects\MyArcGISControlApp\Form1.resx"
The error message may differ from the above error message depending on how the project is set up, what assemblies are referenced, and the install location of the ArcObjects .NET SDK on the machine being used.
This issue occurs when a Visual Studio project contains a resource file (.resx) that is referencing a 32-bit (x86) assembly and is compiled against .NET 3.5 in Visual Studio 2010. Visual Studio uses an executable called 'ResGen.exe' during the build process. This executable is marked as MSIL (Any CPU) and runs as a 64-bit (x64) process on a 64-bit OS. Since the Esri Controls are 32-bit and marked as such, it attempts to load the 32-bit assembly and fails.
The following instructions will make changes to essential Microsoft Visual Studio files and may potentially contain a security risk. Continue at your own risk!
These instructions are an adaptation of a solution provided by Microsoft. Esri is not responsible for any damage that this may cause to your Visual Studio install. It is recommended that you back up the <install location>\Microsoft SDKs\Windows\v7.0A\bin\ResGen.exe before proceeding.
Workaround for VS2010 .NET 3.5 application referencing x86 assembly in resx file on 64-bit OS
<ForceResGen32Bit Condition="'$(MSBuildToolsVersion)'=='4.0' And '$(PROCESSOR_ARCHITEW6432)'!='' And '$(TargetingClr2Framework)'=='true' And '$(PlatformTarget)'=='x86'">true</ForceResGen32Bit>
<Target Name="BeforeResGen" Condition="'$(ForceResGen32Bit)' == 'true'">
<!-- Copy resgen.exe to intermediate working directory for UAC settings -->
<!-- corflags.exe resgen.exe /32BIT+ /Force-->
Command=""$(TargetFrameworkSDKToolsDirectory)corflags.exe" ResGen.exe /32BIT+ /Force" />
<!-- GenerateResource Task parameters
Using the non-64bit Tracker.exe and indicate resgen.exe has been forced to x86 -->
<Target Name="AfterResGen" Condition="'$(ForceResGen32Bit)' == 'true'">
<RemoveDir Directories="$(ResGenSdkToolsPath)" Condition="Exists('$(ResGenSdkToolsPath)')" />
Get help from ArcGIS experts
Download the Esri Support App