18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

THE V ISUAL BASIC 6 DEVELOPMENT ENVIRONMENT<br />

debugger DLL belongs to the component category, and it doesn’t. What this<br />

means is that anytime a component category is used to automate the loading of a<br />

DLL, the DLL cannot be debugged using the Visual Basic debugger.<br />

This causes problems for many of the ways to extend the framework. The most<br />

common way to extend the framework is to add a command or tool. Previously,<br />

it was discussed how component categories were used in this instance. Remember<br />

that the component category was only used to build the list of commands in the<br />

dialog box. This means that if the command to be debugged is already present on<br />

a toolbar, the Visual Basic debugger can be used. Hence, the procedure for debugging<br />

Visual Basic objects that implement the ICommand interface is to ensure that<br />

the command is added to a toolbar when ArcMap is executed standalone and,<br />

after saving the document, load ArcMap through the debugger.<br />

In some cases, such as extensions and property pages, it is not possible to use the<br />

Visual Basic debugger. If you have access to the Visual C++ debugger, you can<br />

use one of the options outlined below. Fortunately, there are a number of ESRI<br />

Visual Basic Add-ins that make it possible to track down the problem quickly and<br />

effectively. The add-ins, described in <strong>ArcGIS</strong> <strong>Developer</strong> Help in the section<br />

‘Visual Basic <strong>Developer</strong> Add-Ins’, provide error log information including line<br />

and module details. A sample output from an error log is given below; note the<br />

call stack information along with line numbers.<br />

Error Log saved on : 8/28/2000 - 10:39:04 AM<br />

Record Call Stack Sequence - Bottom line is error line.<br />

chkVisible_MouseUp C:\Source\MapControl\Commands\frmLayer.frm Line : 196<br />

RefreshMap C:\Source\MapControl\Commands\frmLayer.frm Line : 20<br />

Description<br />

Object variable or With block variable not set<br />

Alternatives to the Visual Basic debugger<br />

If the Visual Basic debugger and add-ins do not provide enough information, the<br />

Visual C++ debugger can be used, either on its own or with C++ ATL wrapper<br />

classes. The Visual C++ debugger does not run the object to be debugged out of<br />

process from ArcMap, which means that none of the above issues apply. Common<br />

debug commands are given in the Visual C++ section ‘Debugging tips in <strong>Developer</strong><br />

Studio’. Both techniques below require the Visual Basic project to be compiled<br />

with debug symbol information.<br />

The Visual C++ debugger can work with this symbolic debug information and<br />

the source files.<br />

Create debug symbol information using the<br />

Create Symbolic Debug Info option on the<br />

Compile tab of the Project Properties dialog box.<br />

Visual C++ debugger<br />

It is possible to use the Visual C++ debugger directly by attaching to a running<br />

process that has the Visual Basic object to be debugged loaded and setting a break<br />

point in the Visual Basic file. When the line of code is reached, the debugger will<br />

halt execution and step into the source file at the correct line. The required steps<br />

are as follows:<br />

1. Start an appropriate application, such as ArcMap.exe.<br />

Chapter 4 • <strong>Developer</strong> environments • 97

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!