{"record":{"id":"5020f7bcc15d2f62","repo":"dotnet/wpf","slug":"sr-objectreadermultidimensionalarraynotsupported","errorCode":null,"errorMessage":"SR.ObjectReaderMultidimensionalArrayNotSupported","messagePattern":"SR\\.ObjectReaderMultidimensionalArrayNotSupported","errorType":"exception","errorClass":"XamlObjectReaderException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs","lineNumber":1806,"sourceCode":"                    foreach (var ov in propertyInfo.Children)\n                    {\n                        ((ObjectOrValueMarkupInfo)ov).EnsureNoDuplicateNames(namesInCurrentScope);\n                    }\n                }\n            }\n\n            private static string ConvertTypeAndMethodToString(Type type, string methodName, SerializerContext context)\n            {\n                string typestring = context.ConvertXamlTypeToString(context.LocalAssemblyAwareGetXamlType(type));\n\n                return $\"{typestring}.{methodName}\";\n            }\n\n            private static ObjectMarkupInfo ForArray(Array value, SerializerContext context)\n            {\n                if (value.Rank > 1)\n                {\n                    throw new XamlObjectReaderException(SR.ObjectReaderMultidimensionalArrayNotSupported);\n                }\n\n                var type = context.LocalAssemblyAwareGetXamlType(value.GetType());\n\n                var elementType = type.ItemType;\n\n                var items = new MemberMarkupInfo { XamlNode = new XamlNode(XamlNodeType.StartMember, XamlLanguage.Items) };\n                foreach (object item in value)\n                {\n                    items.Children.Add(ForObject(item, context));\n                }\n\n                var objectInfo = new ObjectMarkupInfo()\n                {\n                    XamlNode = new XamlNode(XamlNodeType.StartObject, XamlLanguage.Array),\n                    Object = value,\n                    // Scope = context.ReferenceTable,\n                    Properties =","sourceCodeStart":1788,"sourceCodeEnd":1824,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs#L1788-L1824","documentation":"XamlObjectReader throws this when the object graph contains a multidimensional Array (Rank > 1, e.g. int[,]). XAML markup has no syntax for multidimensional arrays, so such values cannot be round-tripped.","triggerScenarios":"new XamlObjectReader(obj) (or XamlServices round-trip) where the graph includes a property or collection value of an array with Rank > 1 (ForArray is invoked via ForArray(Array, SerializerContext)).","commonSituations":"Numeric/grid data (int[,], double[,]) exposed on serializable classes; image/matrix buffers; porting binary-serialized classes to XAML serialization.","solutions":["Replace multidimensional arrays with jagged arrays (T[][]) which XAML can express","Use a collection-of-collections or a wrapper type (e.g. Matrix class) instead of T[,]","Convert the array to a flat array with known row/col dimensions before reading","Mark the multidimensional array member as not serialized (ignore/visibility attribute)"],"exampleFix":"// before\npublic int[,] Grid { get; set; }\n// after\npublic List<List<int>> Grid { get; set; }","handlingStrategy":"type-guard","validationCode":"if (value is Array a && a.Rank > 1) throw new InvalidOperationException(\"Multidimensional arrays are not XAML-round-trippable\");","typeGuard":"bool IsXamlArray(object v) => v is Array a && a.Rank == 1;","tryCatchPattern":"try { using var r = new XamlObjectReader(obj); ... } catch (XamlObjectReaderException ex) when (ex.Message.Contains(\"MultidimensionalArray\")) { /* convert to jagged/collection */ }","preventionTips":["Prefer jagged arrays or collection-of-collections in serializable models","Wrap matrix data in dedicated types","Check Rank on all Array members before round-tripping"],"tags":["xaml","array","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}