BUG: Multidimensional arrays are not displayed correctly in some debugger windows (326721)



The information in this article applies to:

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

This article was previously published under Q326721

SYMPTOMS

When you debug an application that uses Managed Extensions for C++, multidimensional arrays of primitive types do not display array items correctly in the Watch window, the Locals window, or the Autos window of the debugger.

RESOLUTION

To work around this problem, use managed type (instead of unmanaged type) in a multidimensional array.

For example, the following multidimensional arrays of managed type are displayed correctly in the debugger Watch window:
Int32 multiarray1[,] = __gc new Int32[5,2];
Int32 multiarray2[,] = new Int32[5,2];
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Managed Extensions project. A simple Console application is enough to reproduce the problem.
  2. Replace the default _tmain method with the following code that creates a multidimensional array:
    int _tmain(void)
    {   
        int multiarray[5][2] = {{1,2},{3,4},{5,6},{7,8},{9,10}};
        return 0;
    }
    					
  3. Set a breakpoint on the last line (return 0;).
  4. Build the project, and then press F5 to start the debugger.
  5. In the Locals window, an unlabeled tree appears in the Name column (multiarray does not appear next to the plus sign). Expand the tree and see that values for the array items are not correctly displayed.
  6. In the Watch window, if you add the variable multiarray, you see a similar display as in the previous step, although the Name column in the Watch window displays the correct variable name (multiarray). Expand the tree and see that values for the array items are not correctly displayed.
This code appears correctly in the debugger for a nonmanaged application. Copy the same code into a default nonmanaged console application, and then build the project without the common language runtime compile option ( /clr) to see the correct display of the variable in the debugger Watch windows.

REFERENCES

For additional information about arrays, visit the following MSDN Web site:

Managed Extensions for C++ Specification - 4.5 __gc Arrays
http://msdn.microsoft.com/library/en-us/vcmxspec/html/vcManagedExtensionsSpec_4_5.asp


Modification Type:MajorLast Reviewed:7/29/2005
Keywords:kbvs2002sp1sweep kbbug kbManaged kbpending KB326721