dotnet/runtime · error · Error
NotImplementedException
Error message
NotImplementedException ${element_type} What it means
Thrown by checkViewType() when the element_type of a Span or ArraySegment does not match any of the four supported view types (Byte, Int32, Double, Single). checkViewType validates that the MemoryViewType of a Span/ArraySegment matches the expected element type. If the element_type falls through all four checks, the function throws with the element_type included for diagnosis.
Solutions
- Use one of the four supported Span/ArraySegment element types: Span<byte>, Span<int>, Span<double>, or Span<float>.
- For Span<short> or Span<char>, use Span<byte> or Span<int> and reinterpret/convert on the C# side.
- For Span<long>, use Span<byte> and read values manually, or switch to passing a long[] array if supported.
- Ensure the MemoryViewType of the JS-side Span matches the C# element type.
Example fix
// before (unsupported Span element type)
// C#: [JSExport] public static void Process(Span<short> data) { }
// after (use supported type)
// C#: [JSExport] public static void Process(Span<byte> data) { }
// then reinterpret bytes as shorts on the C# side Defensive patterns
Strategy: validation
Validate before calling
// Validate Span/ArraySegment element type
const supportedViewTypes = new Set(['Byte', 'Int32', 'Double', 'Single']);
function isSupportedViewType(type: string): boolean {
return supportedViewTypes.has(type);
}
// Ensure C# Span/ArraySegment uses byte, int, double, or float Prevention
- Use Span<byte>, Span<int>, Span<double>, or Span<float> for interop.
- Convert Span<short>, Span<char> to Span<byte> and reinterpret on the receiving side.
- Match MemoryViewType to the C# element type when creating JS-side Span/ArraySegment.
When it happens
Trigger: Creating or receiving a Span/ArraySegment with an element type other than Byte, Int32, Double, or Single, and then passing it through a marshaling path that calls checkViewType. This occurs in _marshal_span_to_cs and _marshal_array_segment_to_cs when validating the view type against the expected C# element type.
Common situations: Declaring a C# Span<T> or ArraySegment<T> with T as an unsupported type (e.g., Span<short>, Span<char>, Span<long>). Mismatched element types between the JS Span wrapper and the C# parameter declaration.
Related errors
- NotImplementedException: ArraySegment. For more information…
- NotImplementedException: Span
- JSObject proxy is not supported for
- not implemented
- NotImplementedException: bigint
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/01fb5ded23e1a2d0.
Report an issue: GitHub.
Appendix: source
Thrown at src/mono/browser/runtime/marshal-to-cs.ts:553
mono_assert(gc_handle, "Only roundtrip of ArraySegment instance created by C#");
checkViewType(element_type, value._viewType);
set_arg_type(arg, MarshalerType.ArraySegment);
set_arg_intptr(arg, value._pointer);
set_arg_length(arg, value.length);
set_gc_handle(arg, gc_handle);
}
function checkViewType (element_type: MarshalerType, viewType: MemoryViewType) {
if (element_type == MarshalerType.Byte) {
mono_check(MemoryViewType.Byte == viewType, "Expected MemoryViewType.Byte");
} else if (element_type == MarshalerType.Int32) {
mono_check(MemoryViewType.Int32 == viewType, "Expected MemoryViewType.Int32");
} else if (element_type == MarshalerType.Double) {
mono_check(MemoryViewType.Double == viewType, "Expected MemoryViewType.Double");
} else if (element_type == MarshalerType.Single) {
mono_check(MemoryViewType.Single == viewType, "Expected MemoryViewType.Single");
} else {
throw new Error(`NotImplementedException ${element_type} `);
}
}
View on GitHub (pinned to 60108ba66e)