dotnet/aspnetcore · error · Error
The property ' ' is not defined or is not readable.
Error message
The property '${identifier}' is not defined or is not readable. What it means
Thrown by wrapJSCallAsFunction() in the GetValue case when isReadableProperty() returns false for the named member. A GetValue operation (.NET reading a property/value via interop) requires the property to exist and either be a data property or have a getter. Missing properties, non-function getters, or absent members all trigger this.
Solutions
- Confirm the property exists: 'missingProp' in window.myObj and Object.getOwnPropertyDescriptor(window.myObj, 'missingProp').
- Fix the identifier spelling / update to the new API name.
- Ensure any lazy-initialized properties are set before the interop read.
Example fix
// before (C#)
var v = await JS.InvokeAsync<string>("myObj.titel"); // typo
// after
var v = await JS.InvokeAsync<string>("myObj.title"); Defensive patterns
Strategy: validation
Validate before calling
function isReadable(obj, prop) { if (!(prop in obj)) return false; let o = obj; while (o) { const d = Object.getOwnPropertyDescriptor(o, prop); if (d) return d.hasOwnProperty('value') || (typeof d.get === 'function'); o = Object.getPrototypeOf(o); } return false; } Type guard
function isReadableMember(obj: any, prop: string): boolean { if (!(prop in obj)) return false; let o: any = obj; while (o) { const d = Object.getOwnPropertyDescriptor(o, prop); if (d) return d.hasOwnProperty('value') || typeof d.get === 'function'; o = Object.getPrototypeOf(o); } return false; } Try / catch
try { var v = await JS.InvokeAsync<string>("myObj.title"); } catch (JSException e) when (e.Message.Contains("is not defined or is not readable")) { /* property missing/typo; fix identifier */ } Prevention
- Verify the property exists and is readable with 'prop' in obj and a descriptor check.
- Initialize properties before interop reads them (avoid lazy-init race).
- Re-check identifier spelling after JS library upgrades.
When it happens
Trigger: .NET calls JS.InvokeAsync<T>('myObj.missingProp') to read a value, but missingProp is not present on myObj or its prototype chain. Also when the property exists only as a setter (write-only) or has a non-function getter descriptor.
Common situations: Typo in the property name; property renamed in a JS library version; conditional property that isn't initialized yet at call time; accessing a property defined only with a setter.
Related errors
- Could not find ' ' (' ' was undefined).
- The property ' ' is not writable.
- The value ' ' is not a function.
- Byte array index ' ' does not exist.
- Cannot create a JSObjectReference from the value
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/447f861e1a135504.
Report an issue: GitHub.
Appendix: source
Thrown at src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts:641
switch (callType) {
case JSCallType.FunctionCall:
const func = parent[memberName];
if (func instanceof Function) {
return func.bind(parent);
}
throw new Error(`The value '${identifier}' is not a function.`);
case JSCallType.ConstructorCall:
const ctor = parent[memberName];
if (ctor instanceof Function) {
const bound = ctor.bind(parent);
return (...args: any[]) => new bound(...args);
}
throw new Error(`The value '${identifier}' is not a function.`);
case JSCallType.GetValue:
if (!isReadableProperty(parent, memberName)) {
throw new Error(`The property '${identifier}' is not defined or is not readable.`);
}
return () => parent[memberName];
case JSCallType.SetValue:
if (!isWritableProperty(parent, memberName)) {
throw new Error(`The property '${identifier}' is not writable.`);
}
return (...args: any[]) => parent[memberName] = args[0];
}
}
function isReadableProperty(obj: any, propName: string) {
// Return false for missing property.
if (!(propName in obj)) {
return false;
}
// If the property is present we examine its descriptor, potentially needing to walk up the prototype chain.
while (obj !== undefined) {View on GitHub (pinned to 3600ca084e)