dotnet/runtime · error · Error
NotImplementedException
Error message
NotImplementedException
What it means
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.
Source
Thrown at src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts:38
protected constructor(public _pointer: VoidPtr, public _length: number, public _viewType: MemoryViewType) {
}
abstract dispose(): void;
abstract get isDisposed(): boolean;
_unsafe_create_view(): TypedArray {
// this view must be short lived so that it doesn't fail after wasm memory growth
// for that reason we also don't give the view out to end user and provide set/slice/copyTo API instead
if (this._viewType == MemoryViewType.Byte) {
return new Uint8Array(dotnetApi.localHeapViewU8().buffer, this._pointer as any >>> 0, this._length);
} else if (this._viewType == MemoryViewType.Int32) {
return new Int32Array(dotnetApi.localHeapViewI32().buffer, this._pointer as any >>> 0, this._length);
} else if (this._viewType == MemoryViewType.Double) {
return new Float64Array(dotnetApi.localHeapViewF64().buffer, this._pointer as any >>> 0, this._length);
} else if (this._viewType == MemoryViewType.Single) {
return new Float32Array(dotnetApi.localHeapViewF32().buffer, this._pointer as any >>> 0, this._length);
} else {
throw new Error("NotImplementedException");
}
}
set(source: TypedArray, targetOffset?: number): void {
dotnetAssert.check(!this.isDisposed, "ObjectDisposedException");
const targetView = this._unsafe_create_view();
dotnetAssert.fastCheck(source && targetView && source.constructor === targetView.constructor, () => `Expected ${targetView.constructor}`);
targetView.set(source, targetOffset || 0 >>> 0);
// TODO consider memory write barrier
}
copyTo(target: TypedArray, sourceOffset?: number): void {
dotnetAssert.check(!this.isDisposed, "ObjectDisposedException");
const sourceView = this._unsafe_create_view();
dotnetAssert.fastCheck(target && sourceView && target.constructor === sourceView.constructor, () => `Expected ${sourceView.constructor}`);
const trimmedSource = sourceView.subarray(sourceOffset || 0 >>> 0);
// TODO consider memory read barrier
target.set(trimmedSource);View on GitHub (pinned to 290d5ab72c)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Not user-reachable through normal API; assert build integrity instead
function assertBuildIntegrity() {
const ems: any = (globalThis as any).MONO?.ems;
if (!ems) throw new Error("runtime not initialized");
} Try / catch
try {
span.set(source);
} catch (e) {
if (String(e) === "NotImplementedException") {
// likely loader/runtime mismatch; rebuild and reload
location.reload(true);
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Loader/runtime build mismatch introducing a new MemoryViewType; manually constructing a Span/ArraySegment with a bad viewType; memory corruption of the viewType field.
Related errors
- NotImplementedException: Span
- NotImplementedException ${element_type}
- NotImplementedException: Span
- NotImplementedException ${jsType}. For more information see
- NotImplementedException ${elementType}
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/2d8e6b5483649bf7.
Report an issue: GitHub.