In this topic
- About debugging add-ins in Visual Studio
- Setting the debug start executable
- Stepping through the code
About debugging add-ins in Visual Studio
If an add-in has problems or runtime errors occur in the add-in code, use Visual Studio to debug the add-in. For example, if the add-in shows on the Add-Ins dialog box in the application, but a Button, DockWindow, or Gallery does not show on the Ribbon, debugging can help resolve the problem.
Debugging is also useful when first beginning with ArcGIS Explorer development. The debugging process can be used to execute each line of code to run through the flow of code execution.
Setting the debug start executable
When an add-in project is created using ArcGIS Explorer templates, the debug start action is set to automatically debug using the ArcGIS Explorer application in the install location on the developer machine.
If the location of your ArcGIS Explorer installation changes after creating an add-in project, the location might need to be updated in the project debug properties to point to the correct location. This might also be required if an add-in project created on another machine is opened, or if one of the software development kit (SDK) sample add-ins is opened.
Do the following steps to set the debug start action for an add-in project:
- Start Visual Studio.
- Right-click the project in the Solution Explorer and choose Properties.
- On the Project Properties page, choose Debug.
- On the Debug properties page, under the Start Action section, select the Start external program check box.
- In the text box, type the location of the E3.exe application executable on your machine. Alternatively, click Browse to navigate to this location.
- Add some breakpoints to your project. Open the code window for the class to which you want to add a break point, then click the margin indicator bar (the gray area immediately to the left of the Code Editor window) to set a breakpoint.
- Click the Debug menu and choose Start Debugging, or press F5 to start the debugging session. Visual Studio starts ArcGIS Explorer.
Setting debugging start action for class libraries (projects that create .dll files) is not supported by Visual Studio Express editions. The previous steps in this topic apply to non-Express versions.
Stepping through the code
When ArcGIS Explorer loads the add-in that you are currently running in debug mode and hits a breakpoint, focus automatically switches from ArcGIS Explorer to Visual Studio. This process can be referred to as "breaking in" to the class that has the breakpoint.
Use the commands under the Debug menu in Visual Studio to step through each line of code.