Microsoft KB Archive/814058

= You receive a &quot;C2691&quot; error code when you use a jagged array in Managed Extensions for C++ =

Article ID: 814058

Article Last Modified on 5/11/2007

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition

-



SYMPTOMS
If you declare a jagged array, or use a function that returns a jagged array, you receive the following compilation error while compiling the code:

mytest.cpp(6) : error C2691: '  __gc[]' : invalid type for __gc array element

where   is the data type of the jagged array.



CAUSE
A jagged array is not supported in the products that are listed in &quot;Applies To&quot; section of this article.



STATUS
This behavior is by design.



Declaring a Jagged Array
 Click Start, point to All Programs, point to Microsoft Visual Studio .NET, point to Visual Studio .NET Tools, and then click Visual Studio .NET Command Prompt.  Paste the following code in Notepad: using namespace System; void main {   Int32 myJaggedArray[][] = new Int32 [50][]; return; }  Save the file as MyTest.cpp.  At the command prompt, type the following command to compile the code: cl /clr MyTest.cpp  At the command prompt, you receive the compilation error that is described in the &quot;Symptoms&quot; section of this article.
 * 1) using <mscorlib.dll>

Using a Jagged Array
 Click Start, point to All Programs, point to Microsoft Visual Studio .NET, point to Visual Studio .NET Tools, and then click Visual Studio .NET Command Prompt.</li>  Paste the following code in Notepad: using namespace System::Drawing::Imaging; void main {   ImageCodecInfo::GetImageEncoders; return; } The GetImageEncoders method returns a jagged array. </li> Save the file as MyTest.cpp .</li> At the command prompt, type the following command to compile the code:
 * 1) using <mscorlib.dll>
 * 2) using <System.Drawing.dll>

cl /clr MyTest.cpp

</li> At the command prompt, you receive the compilation error that described in the &quot;Symptoms&quot; section of this article.</li></ol>

Note The following is the list of the fields, properties, and methods that return a jagged array in the .NET Framework: Assembly: Microsoft.JScript.dll Field Type: Microsoft.JScript.TypeReflector::System.Reflection.MemberInfo[][] memberInfos

Assembly: mscorlib.dll Field Type: System.Reflection.Emit.AssemblyBuilderData::Byte[][] m_CABytes Field Type: System.Reflection.Emit.LocalSymInfo::Byte[][] m_ubSignature

Assembly: D:\WINDOWS\Microsoft.NET\Framework\v1.0.4207\System.Data.dll Field Type: System.Data.SqlClient.SqlDataReader::System.String[][] _tableNamesShilohSP1 Method Return Type: System.Data.SqlClient.SqlDataReader::System.String[][] get_TableNamesShilohSP1 Method Parameter: System.Data.SqlClient.SqlDataReader::Void set_TableNamesShilohSP1(System.String[][]) Property: System.Data.SqlClient.SqlDataReader::System.String[][] TableNamesShilohSP1 Method Return Type: System.Data.SqlClient.TdsParser::System.String[][] ProcessTableNameShilohSP1(Int32)

Assembly: System.dll Field Type: System.Text.RegularExpressions.RegexBoyerMoore::Int32[][] _negativeUnicode Field Type: System.Text.RegularExpressions.Match::Int32[][] _matches Field Type: System.Text.RegularExpressions.MatchSparse::Int32[][] _matches

Assembly: System.Drawing.dll Constructor Parameter: System.Drawing.Imaging.ColorMatrix::Void .ctor(Single[][]) Method Parameter: System.Drawing.Imaging.ColorMatrix::Void SetMatrix(Single[][]) Method Return Type: System.Drawing.Imaging.ColorMatrix::Single[][] GetMatrix Field Type: System.Drawing.Imaging.ImageCodecInfo::Byte[][] signaturePatterns Field Type: System.Drawing.Imaging.ImageCodecInfo::Byte[][] signatureMasks Method Return Type: System.Drawing.Imaging.ImageCodecInfo::Byte[][] get_SignaturePatterns Method Parameter: System.Drawing.Imaging.ImageCodecInfo::Void set_SignaturePatterns(Byte[][]) Method Return Type: System.Drawing.Imaging.ImageCodecInfo::Byte[][] get_SignatureMasks Method Parameter: System.Drawing.Imaging.ImageCodecInfo::Void set_SignatureMasks(Byte[][]) Property: System.Drawing.Imaging.ImageCodecInfo::Byte[][] SignaturePatterns Property: System.Drawing.Imaging.ImageCodecInfo::Byte[][] SignatureMasks

Assembly: System.Runtime.Remoting.dll Field Type: System.IO.ByteBufferPool::Byte[][] _bufferPool

Assembly: System.Web.dll Method Return Type: System.Web.HttpWorkerRequest::System.String[][] GetUnknownRequestHeaders Field Type: System.Web.Hosting.ISAPIWorkerRequest::System.String[][] _unknownRequestHeaders Method Return Type: System.Web.Hosting.ISAPIWorkerRequest::System.String[][] GetUnknownRequestHeaders Method Return Type: System.Web.Hosting.ISAPIWorkerRequestInProc::System.String[][] GetUnknownRequestHeaders Method Return Type: System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6::System.String[][] GetUnknownRequestHeaders Method Return Type: System.Web.Hosting.ISAPIWorkerRequestOutOfProc::System.String[][] GetUnknownRequestHeaders Method Return Type: System.Web.Hosting.SimpleWorkerRequest::System.String[][] GetUnknownRequestHeaders Method Return Type: System.Web.SessionState.StateHttpWorkerRequest::System.String[][] GetUnknownRequestHeaders Field Type: System.Web.Util.WildcardPath::System.Text.RegularExpressions.Regex[][] _dirs Method Return Type: System.Web.Util.WildcardPath::System.Text.RegularExpressions.Regex[][] DirsFromWildcard(System.String) Method Return Type: System.Web.Util.WildcardUrl::System.Text.RegularExpressions.Regex[][] DirsFromWildcard(System.String)

Assembly: vjslib.dll Field Type: com.ms.vjsharp.text.FormatInfo::System.String[][] __zoneStrings Method Return Type: com.ms.vjsharp.text.FormatInfo::System.String[][] getZoneStrings Method Return Type: java.util.ListResourceBundle::System.Object[][] getContents Method Return Type: java.awt.GridBagLayout::Double[][] getLayoutWeights Method Return Type: java.awt.GridBagLayout::Int32[][] getLayoutDimensions Field Type: com.ms.vjsharp.security.provider.DSAKeyPairGenerator::SByte[][] m_rgbParams Field Type: java.text.DateFormatSymbols::System.String[][] __zoneStrings Method Parameter: java.text.DateFormatSymbols::Void setZoneStrings(System.String[][]) Method Return Type: java.text.DateFormatSymbols::System.String[][] getZoneStrings Method Return Type: java.applet.Applet::System.String[][] getParameterInfo

Assembly: vjswfchtml.dll Field Type: com.ms.wfc.html.DhKeyValuePairs::Char[][] m_cvalues Field Type: com.ms.wfc.html.DhNameValuePairs::Char[][] strings

<div class="references_section">