Error: CS0103: The name 'ArcMap' does not exist in the current context
Building add-in projects on a 32-bit Microsoft Windows operating system returns the following error message.
Error: Error CS0103 The name 'ArcMap' does not exist in the current context ArcMapAddin1 … Warning Cannot find custom tool 'ArcGISAddInHostGenerator' on this system. …
The error is only returned when using a 32-bit Windows operating system. This error may be returned through the following workflow:
- Create a new add-in ArcMap project using the ArcMap Add-in template.
- In the ArcGIS Add-Ins Wizard, accept the Welcome defaults.
- On the next wizard screen check Button for Add-in Types.
- Click Finish to create the add-in project.
- Building the add-in project returns the error message.
ArcGISAddInHostGenerator is a custom tool installed with the ArcObjects SDK that generates the code-behind file for Config.esriAddinx. The ArcObjects SDK does not update the 32-bit Windows registry with the correct keys that Visual Studio and ArcGISAddInHostGenerator must have to work correctly. The code-behind file for Config.esriAddinx is not generated, and compilation fails.
Solution or Workaround
When compiling add-ins on a supported 32-bit operating system (Windows 7 or Windows 8.1) on versions 10.4 through 10.6, download the .zip file corresponding to the ArcObjects SDK release.
Use the 10.4 .zip file for 10.4 and 10.4.1, the 10.5 .zip file for 10.5 and 10.5.1, and the 10.6 .zip file for 10.6 and 10.6.1.
Each .zip file contains a .reg file and a .unreg file. The .reg file writes the correct keys for the supported versions of Visual Studio and the .unreg file removes them. For versions 10.4.x and 10.5.x, the corresponding .reg/.unreg files fix both Visual Studio 2013 and Visual Studio 2015. For 10.6.x, the corresponding .reg/.unreg files fix Visual Studio 2015. There is no issue with Visual Studio 2017 at 10.6.x, so no fix is required.