FIX: Old address in Memory window may cause unhandled exception in Visual Studio .NET (319837)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Professional Edition SP1
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition SP1
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition SP1
  • Microsoft Visual Studio .NET (2002), Academic Edition SP1

This article was previously published under Q319837

SYMPTOMS

When you debug a managed application, a memory address that is left in the Memory window from a previous debug session may cause the debugger to generate an unhandled exception. This problem only occurs in managed applications if the expression that is left in the Memory window is a function + offset expression.

RESOLUTION

If the debugger does not generate an unhandled exception immediately when you start the debugger, follow these steps to work around this problem:
  1. Press F10 to step into Main.
  2. Set the expression in the Memory window to 0.
  3. Press F10 again to continue stepping through your code.
If the exception occurs immediately when you start the debugger, try to create a new Microsoft Visual C# .NET or Microsoft Visual Basic .NET Console Application project, and then reset the garbage value in the Address box of the Memory window by using this project:
  1. Create a new default Visual C# .NET or Visual Basic .NET Console Application project.
  2. Press F10 to step into Main.
  3. Set the expression in the Memory window to 0.
  4. Stop debugging. This clears the old value that was causing the problem in the Address box of the Memory window.
  5. Load your original project that causes the exception, and then step through the code.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in all versions of Microsoft Visual Studio .NET (2003).

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Visual C# .NET Console Application project. Note that you can also reproduce the behavior with a Visual Basic .NET application.
  2. Add the following function to the application:
    static void TestMemoryWindow()
    {
         Console.WriteLine("Testing");
    }
    					
  3. Call TestMemoryWindow in Main().
  4. Build the application and press F10 to start debugging. The application breaks at the call to TestMemoryWindow().
  5. Press F11 to step into the TestMemoryWindow function.
  6. On the Debug menu, point to Windows, click Memory, and then click Memory1 to open the Memory window. You can open any of the four Memory windows.
  7. Type the following in the Address box:

    TestMemoryWindow + 12

  8. Press ENTER.
  9. Stop the debugger.
  10. Press F10 to start debugging.
  11. Press F10 again. This will cause an unhandled exception.

Modification Type:MinorLast Reviewed:8/29/2005
Keywords:kbvs2002sp1sweep kbfix kbBug kbDebug KB319837