{"record":{"id":"fe228da4ca3f63c9","repo":"dotnet/runtime","slug":"notimplementedexception-elementtype-for-more-i","errorCode":null,"errorMessage":"NotImplementedException ${elementType}. 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/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-js.ts","lineNumber":470,"sourceCode":"        }\n    } else if (elementType == MarshalerType.Byte) {\n        const bufferOffset = fixupPointer(bufferPtr, 0);\n        const sourceView = dotnetApi.localHeapViewU8().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else if (elementType == MarshalerType.Int32) {\n        const bufferOffset = fixupPointer(bufferPtr, 2);\n        const sourceView = dotnetApi.localHeapViewI32().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else if (elementType == MarshalerType.Double) {\n        const bufferOffset = fixupPointer(bufferPtr, 3);\n        const sourceView = dotnetApi.localHeapViewF64().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else if (elementType == MarshalerType.Single) {\n        const bufferOffset = fixupPointer(bufferPtr, 2);\n        const sourceView = dotnetApi.localHeapViewF32().subarray(bufferOffset, bufferOffset + length);\n        result = sourceView.slice();//copy\n    } else {\n        throw new Error(`NotImplementedException ${elementType}. ${jsinteropDoc}`);\n    }\n    Module._free(<any>bufferPtr);\n    return result;\n}\n\nfunction _marshalSpanToJs(arg: JSMarshalerArgument, elementType?: MarshalerType): Span {\n    dotnetAssert.check(!!elementType, \"Expected valid elementType parameter\");\n\n    const bufferPtr = getArgIntptr(arg);\n    const length = getArgLength(arg);\n    let result: Span | null = null;\n    if (elementType == MarshalerType.Byte) {\n        result = new Span(<any>bufferPtr, length, MemoryViewType.Byte);\n    } else if (elementType == MarshalerType.Int32) {\n        result = new Span(<any>bufferPtr, length, MemoryViewType.Int32);\n    } else if (elementType == MarshalerType.Double) {\n        result = new Span(<any>bufferPtr, length, MemoryViewType.Double);\n    } else if (elementType == MarshalerType.Single) {","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-js.ts#L452-L488","documentation":"Thrown by the C#-to-JS array marshaler (_marshalArrayToJs) when elementType is none of String/Object/JSObject/Byte/Int32/Double/Single. It is the JS-side mirror of the array marshaler else branch: the runtime tried to materialize a JS array from a managed array of an unsupported element type.","triggerScenarios":"A C# method declared with [return: JSMarshalAsAttribute<JSType.Array<...>>] using an unsupported inner element type, or a JS-visible field/property of an unsupported array element kind.","commonSituations":"Returning char[], bool[], DateTime[], enum[], or struct[] arrays to JS; mismatched JSType generic arguments between the attribute and the actual type.","solutions":["Return one of the supported array types (byte[], int[], double[], float[], string[], object[], JSObject[]).","Box or convert unsupported element types before returning (e.g. bool[] -> byte[], char[] -> int[])."],"exampleFix":"// before\n[return: JSMarshalAsAttribute<JSType.Array<JSType.Char>>()]\nstatic partial char[] GetText();\n\n// after\n[return: JSMarshalAsAttribute<JSType.Array<JSType.Int32>>()]\nstatic partial int[] GetText();","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"Byte\",\"Int32\",\"Double\",\"Single\",\"String\",\"Object\",\"JSObject\"]);\nfunction checkReturnArray(jsType: string) {\n    if (!SUPPORTED.has(jsType)) throw new Error(`Cannot return array of ${jsType} to JS`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare [return: JSMarshalAsAttribute<JSType.Array<...>>] with a supported inner type.","Convert unsupported element types in C# before returning."],"tags":["marshaling","array","element-type","interop","csharp-to-js"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}