{"record":{"id":"2d8e6b5483649bf7","repo":"dotnet/runtime","slug":"notimplementedexception-2d8e6b","errorCode":null,"errorMessage":"NotImplementedException","messagePattern":"NotImplementedException","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts","lineNumber":38,"sourceCode":"    protected constructor(public _pointer: VoidPtr, public _length: number, public _viewType: MemoryViewType) {\n    }\n\n    abstract dispose(): void;\n    abstract get isDisposed(): boolean;\n\n    _unsafe_create_view(): TypedArray {\n        // this view must be short lived so that it doesn't fail after wasm memory growth\n        // for that reason we also don't give the view out to end user and provide set/slice/copyTo API instead\n        if (this._viewType == MemoryViewType.Byte) {\n            return new Uint8Array(dotnetApi.localHeapViewU8().buffer, this._pointer as any >>> 0, this._length);\n        } else if (this._viewType == MemoryViewType.Int32) {\n            return new Int32Array(dotnetApi.localHeapViewI32().buffer, this._pointer as any >>> 0, this._length);\n        } else if (this._viewType == MemoryViewType.Double) {\n            return new Float64Array(dotnetApi.localHeapViewF64().buffer, this._pointer as any >>> 0, this._length);\n        } else if (this._viewType == MemoryViewType.Single) {\n            return new Float32Array(dotnetApi.localHeapViewF32().buffer, this._pointer as any >>> 0, this._length);\n        } else {\n            throw new Error(\"NotImplementedException\");\n        }\n    }\n\n    set(source: TypedArray, targetOffset?: number): void {\n        dotnetAssert.check(!this.isDisposed, \"ObjectDisposedException\");\n        const targetView = this._unsafe_create_view();\n        dotnetAssert.fastCheck(source && targetView && source.constructor === targetView.constructor, () => `Expected ${targetView.constructor}`);\n        targetView.set(source, targetOffset || 0 >>> 0);\n        // TODO consider memory write barrier\n    }\n\n    copyTo(target: TypedArray, sourceOffset?: number): void {\n        dotnetAssert.check(!this.isDisposed, \"ObjectDisposedException\");\n        const sourceView = this._unsafe_create_view();\n        dotnetAssert.fastCheck(target && sourceView && target.constructor === sourceView.constructor, () => `Expected ${sourceView.constructor}`);\n        const trimmedSource = sourceView.subarray(sourceOffset || 0 >>> 0);\n        // TODO consider memory read barrier\n        target.set(trimmedSource);","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts#L20-L56","documentation":"Thrown by Span/ArraySegment._unsafe_create_view when the stored MemoryViewType is none of Byte/Int32/Double/Single. This is an internal invariant violation: a view object exists whose viewType was set to an unexpected/unknown enum value, so the runtime cannot build a TypedArray over wasm memory for it.","triggerScenarios":"Corruption or version skew causing MemoryViewType to take an unrecognized value (e.g. a future enum member the loaded JS lib doesn't know). It is not reachable through normal API usage with the four supported view types.","commonSituations":"Loader/runtime build mismatch introducing a new MemoryViewType; manually constructing a Span/ArraySegment with a bad viewType; memory corruption of the viewType field.","solutions":["Rebuild and reload so the JS interop library and the .NET WASM runtime match exactly.","Avoid constructing Span/ArraySegment instances directly in user JS code; only use those returned by C#.","File an issue with the runtime/git hash if it reproduces on a clean matching build."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Not user-reachable through normal API; assert build integrity instead\nfunction assertBuildIntegrity() {\n    const ems: any = (globalThis as any).MONO?.ems;\n    if (!ems) throw new Error(\"runtime not initialized\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    span.set(source);\n} catch (e) {\n    if (String(e) === \"NotImplementedException\") {\n        // likely loader/runtime mismatch; rebuild and reload\n        location.reload(true);\n    } else throw e;\n}","preventionTips":["Never construct Span/ArraySegment directly in user JS.","Keep loader and runtime artifacts from the exact same build.","Treat this throw as a defect to report, not a normal path."],"tags":["marshaling","span","invariant","version-mismatch","internal"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}