Microsoft KB Archive/326721

= BUG: Multidimensional arrays are not displayed correctly in some debugger windows =

Article ID: 326721

Article Last Modified on 7/29/2005

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * 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 &quot;Applies to&quot; section.



Steps to Reproduce the Behavior
 Create a new Managed Extensions project. A simple Console application is enough to reproduce the problem.  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; }                    Set a breakpoint on the last line (return 0;). Build the project, and then press F5 to start the debugger. 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. 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.</li></ol>

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.

<div class="references_section">