English

Problem: Unexpected results using Visual Basic's debugger

Description

When debugging a Visual Basic DLL, one of the following problems occurs:

- The bitmap defined in the implementation of ICommand does not appear on the toolbar while in debug mode.
- Trying to QueryInterface to a valid interface fails.
- An error is returned when executing IFeatureClass::Select against SDE data.
- ArcMap hangs in debug mode.

Cause

When the application is run in debug mode, Visual Basic exchanges the CLSID of the component and ArcMap loads the VB6Debug.dll into memory instead of the component. The debugger forwards requests to the ActiveX DLL projects, allowing the user to debug interactively with Visual Basic. Since VB6Debug.dll is running in a different process space than ArcMap, a special marshalling code is required to pass objects across boundaries. This special marshalling is the cause of the debug problems.

Solution or Workaround

  • Use the ESRI Error Handler and Line Number Generator AddIns from ArcObjectsOnline when creating the application. See the link in Related Information, below.
  • Debug the Visual Basic application using C++ debugger.
     
    To debug ArcObjects code written in Visual Basic, use either ESRI add-ins (ESRI ErrorHandler & ESRI Line Number Generator) or run their VB code in C++'s debugger.
    More information about ESRI add-ins is available in the Utilities folder of ArcObjects Developer Help.

    Procedure:
    Follow these steps to use Visual C++ to debug a Visual Basic ActiveX DLL ArcObjects application.
    Note:
    Steps 1-3 apply to the Visual Basic project; the remaining steps apply to Visual C++.
    1. In the Visual Basic ActiveX DLL project, click Project > Properties > Compile.
    2. Check Create Symbolic Debug Info.
    3. Click File > Make xxxx.dll, to recompile the DLL and create the PDB file.
    4. Start VC++. Close any open workspaces.
      Warning:	
      You must have Visual C++ installed in order to continue.
    5. Click File > Open and navigate to the Visual Basic class file (.cls) of your Visual Basic ActiveX DLL project.
    6. Press F5 to run the program (Build > Start Debug > Go).
    7. Click Yes to create a project.
    8. Click No; you do not want to create an EXE.
    9. Click Project > Settings > Debug.
    10. Click Category General. Set 'Executable for debug session' to ..\arcexe82\bin\ArcMap.exe.
    11. From the Category dropdown list, click Additional DLLs. Navigate to your Visual Basic DLL and click OK.
    12. Set break points in the code by going to the line where you want to start, and press F9.
    13. Press F5 to run the program.
    14. Check the box ..\arcgis\arcexe82\bin\ArcMap.exe and click OK.
    15. Press F10/F11 to step through the code.
      Note:
      When you step through the code and the debugger reaches a line that has a problem, it will not let you step over to the next line.

Related Information