{"record":{"id":"a1b25dda8727364c","repo":"dotnet/runtime","slug":"notimplementedexception-element-type-for-more","errorCode":null,"errorMessage":"NotImplementedException ${element_type}. For more information see https://aka.ms/dotnet-wasm-jsinterop","messagePattern":"NotImplementedException (.+?)\\. For more information see https://aka\\.ms/dotnet-wasm-jsinterop","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/marshal-to-js.ts","lineNumber":544,"sourceCode":"        }\n    } else if (element_type == MarshalerType.Byte) {\n        const bufferOffset = fixupPointer(buffer_ptr, 0);\n        const sourceView = localHeapViewU8().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else if (element_type == MarshalerType.Int32) {\n        const bufferOffset = fixupPointer(buffer_ptr, 2);\n        const sourceView = localHeapViewI32().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else if (element_type == MarshalerType.Double) {\n        const bufferOffset = fixupPointer(buffer_ptr, 3);\n        const sourceView = localHeapViewF64().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else if (element_type == MarshalerType.Single) {\n        const bufferOffset = fixupPointer(buffer_ptr, 2);\n        const sourceView = localHeapViewF32().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else {\n        throw new Error(`NotImplementedException ${element_type}. ${jsinteropDoc}`);\n    }\n    free(<any>buffer_ptr);\n    return result;\n}\n\nfunction _marshal_span_to_js (arg: JSMarshalerArgument, element_type?: MarshalerType): Span {\n    mono_assert(!!element_type, \"Expected valid element_type parameter\");\n\n    const buffer_ptr = get_arg_intptr(arg);\n    const length = get_arg_length(arg);\n    let result: Span | null = null;\n    if (element_type == MarshalerType.Byte) {\n        result = new Span(<any>buffer_ptr, length, MemoryViewType.Byte);\n    } else if (element_type == MarshalerType.Int32) {\n        result = new Span(<any>buffer_ptr, length, MemoryViewType.Int32);\n    } else if (element_type == MarshalerType.Double) {\n        result = new Span(<any>buffer_ptr, length, MemoryViewType.Double);\n    } else if (element_type == MarshalerType.Single) {","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/marshal-to-js.ts#L526-L562","documentation":"_marshal_array_to_js builds a JS array from a C# array. Supported element types are String, Object, JSObject, Byte, Int32, Double, and Single. Any other MarshalerType reaches the default branch and throws, naming the unsupported element_type.","triggerScenarios":"A C# method returns or marshals an array whose element type is not in the supported set (e.g. an array of a struct, enum with unsupported backing, bool[], short[], long[]). The element_type is set by the C# signature.","commonSituations":"Declaring a [JSExport] return type of T[] where T is unsupported by the JS marshaler; returning bool[] or long[] arrays.","solutions":["Change the C# element type to one supported by JS interop: string, int, double, float, byte, JSObject/object, or a Task.","For long elements, return long[] is unsupported; marshal as a typed buffer (Span<long> is also unsupported, so use int[]/double[] or split).","Project structs into plain objects (object[]) or JSON strings before crossing to JS."],"exampleFix":"// C# before\n[JSExport] public static bool[] GetFlags() => new[] { true, false };\n// after\n[JSExport] public static int[] GetFlags() => new[] { 1, 0 };","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return dotnet.jsExports.GetArray(); } catch (e) { if (String(e?.message).startsWith('NotImplementedException') && String(e?.message).includes('https://aka.ms/dotnet-wasm-jsinterop')) { return JSON.parse(dotnet.jsExports.GetArrayJson()); } throw e; }","preventionTips":["Return arrays of supported element types (string, int, double, float, byte, object, JSObject).","For unsupported element types, serialize to JSON or project into a supported array on the C# side.","Avoid bool[]/long[]/short[]/struct[] across the JS boundary."],"tags":["marshaling","interop","array"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}