{"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/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/browser/runtime/marshal-to-js.ts#L526-L562","documentation":"Thrown by _marshal_array_to_js_impl() as the final else when the C#-to-JS array element type does not match any supported type (String, Object, JSObject, Byte, Int32, Double, Single). This fires when C# returns an array with an element type that the JS marshaler cannot convert. The element_type value is included in the message along with a doc link.","triggerScenarios":"A C# JSExport method returns an array whose element type is not one of the supported marshalable types (e.g., returns char[], short[], decimal[], long[], bool[]). The C#-side marshaler binding generates the element_type code, and _marshal_array_to_js_impl throws on unrecognized types.","commonSituations":"Returning unsupported array types from C# JSExport methods. Using a C# return type like char[] or long[] from an interop method. Version mismatch between the runtime and the C# signature generator.","solutions":["Change the C# return type to a supported array type: string[], int[], byte[], double[], float[], or object[].","For bool[], return byte[] (0/1) and convert on the JS side.","For char[] or short[], return int[] and convert on the JS side.","For long[], return a long[] if BigInt64 is supported, or return string[] with serialized values.","Ensure the C# project and the JS runtime package are at compatible versions."],"exampleFix":"// before (unsupported return type)\n// C#: [JSExport] public static char[] GetData() { ... }\n\n// after (supported return type)\n// C#: [JSExport] public static int[] GetData() => chars.Select(c => (int)c).ToArray();\n// JS:  const chars = GetData().map(c => String.fromCharCode(c));","handlingStrategy":"validation","validationCode":"// Validate C# return array type at design time\n// Only these array types are supported for C#-to-JS marshaling:\nconst supportedReturnArrayTypes = ['string[]', 'int[]', 'byte[]', 'double[]', 'float[]', 'object[]'];\n// Ensure your JSExport/JSImport return types match this list","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Return supported array types from C# JSExport methods: string[], int[], byte[], double[], float[], object[].","Convert unsupported types (char[], short[], bool[], long[]) on the C# side before returning.","Keep C# and JS runtime versions aligned to avoid marshaler mismatches."],"tags":["marshaling","array","type-mismatch","csharp-to-js","interop"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}