{"record":{"id":"039a2f0e1e0f692a","repo":"dotnet/runtime","slug":"notimplementedexception-039a2f","errorCode":null,"errorMessage":"NotImplementedException","messagePattern":"NotImplementedException","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/mono/browser/runtime/marshal.ts","lineNumber":491,"sourceCode":"abstract class MemoryView implements IMemoryView {\n    protected constructor (public _pointer: VoidPtr, public _length: number, public _viewType: MemoryViewType) {\n        this._pointer = fixupPointer(_pointer, 0);\n    }\n\n    abstract dispose(): void;\n    abstract get isDisposed(): boolean;\n\n    _unsafe_create_view (): TypedArray {\n        if (this._viewType == MemoryViewType.Byte) {\n            return new Uint8Array(localHeapViewU8().buffer, this._pointer as any, this._length);\n        } else if (this._viewType == MemoryViewType.Int32) {\n            return new Int32Array(localHeapViewI32().buffer, this._pointer as any, this._length);\n        } else if (this._viewType == MemoryViewType.Double) {\n            return new Float64Array(localHeapViewF64().buffer, this._pointer as any, this._length);\n        } else if (this._viewType == MemoryViewType.Single) {\n            return new Float32Array(localHeapViewF32().buffer, this._pointer as any, this._length);\n        } else {\n            throw new Error(\"NotImplementedException\");\n        }\n    }\n\n    set (source: TypedArray, targetOffset?: number): void {\n        mono_check(!this.isDisposed, \"ObjectDisposedException\");\n        const targetView = this._unsafe_create_view();\n        mono_check(source && targetView && source.constructor === targetView.constructor, () => `Expected ${targetView.constructor}`);\n        targetView.set(source, targetOffset);\n        // TODO consider memory write barrier\n    }\n\n    copyTo (target: TypedArray, sourceOffset?: number): void {\n        mono_check(!this.isDisposed, \"ObjectDisposedException\");\n        const sourceView = this._unsafe_create_view();\n        mono_check(target && sourceView && target.constructor === sourceView.constructor, () => `Expected ${sourceView.constructor}`);\n        const trimmedSource = sourceView.subarray(sourceOffset);\n        // TODO consider memory read barrier\n        target.set(trimmedSource);","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/browser/runtime/marshal.ts#L473-L509","documentation":"Thrown by MemoryView._unsafe_create_view() in marshal.ts when the memory view's _viewType does not match any of the known MemoryViewType cases (Byte, Int32, Double, Single). It is a developer-facing guard marking an unimplemented code path rather than a user error. Hitting it means the runtime created a MemoryView with a viewType that has no backing TypedArray mapping. This indicates either a new MemoryViewType was added without updating the factory, or memory corruption fed an invalid viewType integer.","triggerScenarios":"Constructing a MemoryView subclass instance whose _viewType field holds a value outside the 0..3 range of MemoryViewType, then calling set(), copyTo(), slice(), or any method that calls _unsafe_create_view(). Also reachable if the _viewType property is overwritten after construction.","commonSituations":"A new typed-memory-view variant is added to the marshaler enum but the switch in _unsafe_create_view is not updated; or an object's memory is misaligned/corrupted so the viewType byte reads as an unknown value. This is essentially never seen in normal API usage.","solutions":["Confirm the MemoryView subclass was constructed with a valid MemoryViewType (Byte=0, Int32=1, Double=2, Single=3).","If you extended MemoryViewType, add the corresponding branch to _unsafe_create_view in src/mono/browser/runtime/marshal.ts:491.","If the value is being read from native/shared memory, verify the source buffer is not being overwritten out of band (thread race / buffer overrun)."],"exampleFix":"// before\nconst view = new SomeMemoryView(ptr, len, 99); // invalid viewType\n// after\nconst view = new SomeMemoryView(ptr, len, MemoryViewType.Int32);","handlingStrategy":"validation","validationCode":"function isValidViewType(t: number): boolean {\n  return t === MemoryViewType.Byte\n      || t === MemoryViewType.Int32\n      || t === MemoryViewType.Double\n      || t === MemoryViewType.Single;\n}\n// assert isValidViewType(view._viewType) before calling methods that build a TypedArray","typeGuard":"function isKnownViewType(t: unknown): t is number {\n  return typeof t === 'number' && t >= 0 && t <= 3;\n}","tryCatchPattern":null,"preventionTips":["Treat NotImplementedException from the marshaler as a bug - file it upstream rather than catching it.","If you extend MemoryViewType, immediately update the switch in _unsafe_create_view.","Avoid mutating the _viewType field after construction."],"tags":["marshaler","memory-view","internal-error","typescript"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}