How to debug a Visual Basic .NET or Visual Basic 2005 application that does not respond

Article translations Article translations
Article ID: 318357 - View products that this article applies to.
This article was previously published under Q318357
Beta Information
This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about how to obtain support for a Beta release, see the documentation that is included with the Beta product files, or check the Web location from which you downloaded the release.
Expand all | Collapse all

On This Page

SUMMARY

This step-by-step article describes how to debug a Microsoft Visual Basic .NET or Microsoft Visual Basic 2005 application. Microsoft Visual Studio .NET or Microsoft Visual Studio 2005 debugger can attach to a program that is running in a process outside the Visual Studio environment. The debugger can attach to a process that is not responding. The debugger displays disassembly view and pauses the running process. Based on the availability of the Program DataBase (.pdb) file and source code, the debugger displays the source code with disassembly view.

Requirements

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you must have:
  • Microsoft Windows 2000 or Microsoft Windows XP
  • Microsoft Visual Studio .NET or Microsoft Visual Studio 2005

Use the Debug Class and the Trace Class

You can use the Debug class and the Trace class to provide information about the performance of an application. You can also use these classes to identify problem areas of an application. You can do this during application development or after production deployment. These classes are available in Microsoft .NET Framework. You can use the Trace class to instrument release builds. Instrumentation allows you to monitor the health of your application that is running in real-life settings. Using the Trace class helps you isolate and fix problems without disturbing a running system. You can use the Debug class to print debugging information, and to check your logic with assertions. You can make your code more robust, without impacting the performance and code size of your shipping product.

For additional information about using the Trace class and the Debug class in Visual Basic .NET, click the following article number to view the article in the Microsoft Knowledge Base:
313417 HOW TO: Trace and Debug in Visual Basic .NET

Debug an Application that Does Not Respond


To debug a Visual Basic .NET application, follow these steps:
  1. Open Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
  2. On the Tools menu, click Debug Processes.
  3. In the Processes dialog box, click to select the program that you want to attach from the Available Processes list. If the program you want to debug is running on another computer, you must first click to select the remote computer.

    For more information about selecting a remote computer, visit the following MSDN Web site:

    Selecting a Remote Machine
    http://msdn.microsoft.com/en-us/library/w8wtw2f3(VS.71).aspx
  4. Click Attach.
  5. In the Attach to Process dialog box, make sure the appropriate program type is selected in Choose the program types that you want to debug. For example, to debug a Visual Basic .NET or Visual Basic 2005 application, click to select Common Language Runtime.
  6. Click OK.

    The Processes dialog box is displayed.
  7. In the When debugging is stopped list, click to select Detach from this process when you want the program to detach from the process without quitting. Click to select Terminate this process when you want the program to quit.
  8. Click to select the process in the Debug Processes list box, and then click Break.

    Debugger stops in disassembly view, and the program is paused. If the .pdb file is available in the same directory as the executable, debugger loads the source code.
  9. To view the source code, right-click Disassembly, and then click Go to Source Code to switch to the Code window. Insert a break point where you want it.
  10. On the Debug menu, click Continue or press the F5 key to continue the process.

    The debugger automatically stops when it reaches the breakpoint.
  11. On the Debug menu, click Stop Debugging or press the SHIFT+F5 keyboard shortcut to stop debugging.

Use a Memory Dump File

For your application that is not responding, you can generate a memory dump file. In Windows debugger, you can use the memory dump file to debug the cause of your application not responding. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
286350 HOW TO: Use ADPlus to Troubleshoot "Hangs" and "Crashes"

Troubleshoot

  • If you are debugging a program running on remote computer, install Mdm.exe on the computer. If Mdm.exe is not installed on the remote computer, install Mdm.exe, and then start the process before debugging.
  • If the application is running in Release mode, the Debug class output is ignored.

REFERENCES

For more information, visit the following Microsoft Web site:

Production Debugging for .NET Framework Applications
http://msdn.microsoft.com/en-us/library/ms954594.aspx

Properties

Article ID: 318357 - Last Review: December 6, 2006 - Revision: 3.5
APPLIES TO
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
Keywords: 
kbvs2005swept kbvs2005applies kbnamespace kbmanaged kbdynamic kbdev kbdesigner kbdebug kbhowtomaster KB318357

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com