{"record":{"id":"36b13ff7bdc5d223","repo":"dotnet/runtime","slug":"notimplementedexception-bigint","errorCode":null,"errorMessage":"NotImplementedException: bigint","messagePattern":"NotImplementedException: bigint","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/marshal-to-cs.ts","lineNumber":392,"sourceCode":"}\n\nexport function marshal_cs_object_to_cs (arg: JSMarshalerArgument, value: any): void {\n    if (value === undefined || value === null) {\n        set_arg_type(arg, MarshalerType.None);\n        set_arg_proxy_context(arg);\n    } else {\n        const gc_handle = value[js_owned_gc_handle_symbol];\n        const js_type = typeof (value);\n        if (gc_handle === undefined) {\n            if (js_type === \"string\" || js_type === \"symbol\") {\n                set_arg_type(arg, MarshalerType.String);\n                _marshal_string_to_cs_impl(arg, value);\n            } else if (js_type === \"number\") {\n                set_arg_type(arg, MarshalerType.Double);\n                set_arg_f64(arg, value);\n            } else if (js_type === \"bigint\") {\n                // we do it because not all bigint values could fit into Int64\n                throw new Error(\"NotImplementedException: bigint\");\n            } else if (js_type === \"boolean\") {\n                set_arg_type(arg, MarshalerType.Boolean);\n                set_arg_bool(arg, value);\n            } else if (value instanceof Date) {\n                set_arg_type(arg, MarshalerType.DateTime);\n                set_arg_date(arg, value);\n            } 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);","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/marshal-to-cs.ts#L374-L410","documentation":"In marshal_cs_object_to_cs, when a value is a JS bigint but the C# parameter is typed as object/JSObject (the generic object marshaler), the runtime throws because not every bigint fits in Int64 and the object marshaler has no bigint mapping. The dedicated long marshaler (setI64Big) handles bigints for strongly-typed long parameters, but the object path does not.","triggerScenarios":"Passing a JS bigint to a [JSExport] C# parameter declared as object or JSObject instead of long/long?. The typeof === 'bigint' branch at line 390 throws.","commonSituations":"Mixing JS BigInt with loosely-typed C# interop; sending an int64-sized value as a generic object; JSON.parse producing numbers that the caller wraps in BigInt.","solutions":["Declare the C# parameter as long or long? so the dedicated Int64 marshaler (setI64Big) is used.","Convert the bigint to a Number (if within safe integer range), a string, or a byte array before passing.","If you need arbitrary precision, marshal as a string and parse on the C# side."],"exampleFix":"// C# before\n[JSExport] public static void Take(object v) { }\n// JS: dotnet.jsExports.Take(123n); // throws\n// C# after\n[JSExport] public static void Take(long v) { }","handlingStrategy":"type-guard","validationCode":"if (typeof value === 'bigint') {\n  throw new TypeError('Pass bigints only to C# long/long? parameters, not object/JSObject.');\n}","typeGuard":"function isBigInt(v: unknown): v is bigint { return typeof v === 'bigint'; }","tryCatchPattern":"try { dotnet.jsExports.Take(value); } catch (e) { if (String(e?.message) === 'NotImplementedException: bigint') { /* coerce */ dotnet.jsExports.Take(Number(value)); } else throw e; }","preventionTips":["Match the JS value type to the C# parameter type: bigint -> long.","Avoid object/JSObject parameters for numeric data; use the concrete numeric type.","For arbitrary-precision values, marshal as a string."],"tags":["marshaling","interop","types","bigint"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}