{"record":{"id":"a2e6a9a3c2c090ab","repo":"dotnet/runtime","slug":"notimplementedexception-typedarray","errorCode":null,"errorMessage":"NotImplementedException: TypedArray","messagePattern":"NotImplementedException: TypedArray","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/marshal-to-cs.ts","lineNumber":417,"sourceCode":"            } else if (value instanceof Error) {\n                marshal_exception_to_cs(arg, value);\n            } else if (value instanceof Uint8Array) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Byte);\n            } else if (value instanceof Float32Array) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Single);\n            } else if (value instanceof Float64Array) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Double);\n            } else if (value instanceof Int32Array) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Int32);\n            } else if (Array.isArray(value)) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Object);\n            } else if (value instanceof Int16Array\n                || value instanceof Int8Array\n                || value instanceof Uint8ClampedArray\n                || value instanceof Uint16Array\n                || value instanceof Uint32Array\n            ) {\n                throw new Error(\"NotImplementedException: TypedArray\");\n            } else if (isThenable(value)) {\n                marshal_task_to_cs(arg, value);\n            } else if (value instanceof Span) {\n                throw new Error(\"NotImplementedException: Span\");\n            } else if (js_type == \"object\") {\n                const js_handle = mono_wasm_get_js_handle(value);\n                set_arg_type(arg, MarshalerType.JSObject);\n                if (BuildConfiguration === \"Debug\" && Object.isExtensible(value)) {\n                    value[proxy_debug_symbol] = `JS Object with JSHandle ${js_handle}`;\n                }\n                set_js_handle(arg, js_handle);\n            } else {\n                throw new Error(`JSObject proxy is not supported for ${js_type} ${value}`);\n            }\n        } else {\n            assert_not_disposed(value);\n            if (value instanceof ArraySegment) {\n                throw new Error(\"NotImplementedException: ArraySegment. \" + jsinteropDoc);","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/marshal-to-cs.ts#L399-L435","documentation":"marshal_cs_object_to_cs supports only Uint8Array, Float32Array, Float64Array, Int32Array and plain Array as array-like objects. Other TypedArray variants (Int8Array, Int16Array, Uint8ClampedArray, Uint16Array, Uint32Array) hit the else-branch and throw NotImplementedException: TypedArray.","triggerScenarios":"Passing an Int8Array, Uint16Array, Int16Array, Uint8ClampedArray, or Uint32Array to a C# [JSExport] parameter typed as object/JSObject.","commonSituations":"Using a Uint16Array or Int16Array for audio/graphics data; picking a TypedArray width that is not in the supported set when calling loosely-typed interop.","solutions":["Convert the array to one of the supported views: Uint8Array, Int32Array, Float32Array, Float64Array, or a plain Array.","If the C# parameter should be a typed buffer, declare it as byte[]/int[]/float[]/double[] so the matching array marshaler is selected."],"exampleFix":"// before\ndotnet.jsExports.Take(new Uint16Array([1,2,3])); // throws\n// after\ndotnet.jsExports.Take(new Uint8Array([1,2,3]));\n// or declare C# param as ushort[] via a supported element type","handlingStrategy":"type-guard","validationCode":"const UNSUPPORTED = new Set([Int8Array, Int16Array, Uint16Array, Uint32Array, Uint8ClampedArray]);\nfor (const T of UNSUPPORTED) if (value instanceof T) throw new TypeError(`${T.name} is not supported by the object marshaler; use Uint8Array/Int32Array/Float32Array/Float64Array/Array.`);","typeGuard":"function isSupportedTypedArray(v: unknown): v is Uint8Array | Int32Array | Float32Array | Float64Array { return v instanceof Uint8Array || v instanceof Int32Array || v instanceof Float32Array || v instanceof Float64Array; }","tryCatchPattern":null,"preventionTips":["Stick to Uint8Array, Int32Array, Float32Array, Float64Array, or plain Array for interop.","Declare the C# parameter as the matching element type (byte[]/int[]/float[]/double[]) so the right marshaler is chosen.","Repack Int8/Int16/Uint16/Uint32 data into a supported view before crossing to C#."],"tags":["marshaling","interop","types","typedarray"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}