session.clr is a CLRSessionProxy — available on every NSPSession that is attached to a .NET CLR application. It gives you direct access to the managed runtime: read fields by type name, invoke methods, and snapshot the heap, all without modifying the target application or writing any .NET code.
When to Use session.clr
Use session.clr when the field or method you need is not already surfaced in session.state. The high-level session state (session.get_str(...), session.get_int(...), etc.) reflects the semantic model that the NSP probe has already extracted. session.clr lets you reach below that model — reading raw CLR fields and invoking arbitrary managed methods.
As a rule of thumb:
- Start with
session.statefor any value the probe already exposes. - Use
session.clrwhen you need runtime-specific fields, internal state, or method return values that are not in the semantic model.
CLR helpers require a probe confidence of at least 0.85. If the probe is still attaching,
session.clr calls will raise NSPActionError with code clr_not_attached. Check session.state.runtime == RuntimeKind.CLR and session.confidence >= 0.85 before using CLR methods.Prerequisites
read_field(type_name, field_name, *, timeout_ms)
Read the value of a single .NET field from the target process.
The fully-qualified .NET type name, e.g.
"MissionPlanner.FlightData". Namespace-qualified names are required.The field name, case-sensitive, exactly as it appears in the .NET source.
Maximum time in milliseconds to wait for the CLR bridge to respond.
read_field():
read_fields(type_name, *field_names, timeout_ms)
Read multiple fields from the same type in a single round-trip. This is more efficient than calling read_field() repeatedly.
Fully-qualified .NET type name.
One or more field names to read.
Maximum time in milliseconds to wait for the CLR bridge.
invoke(type_name, method_name, args, *, timeout_ms)
Invoke a .NET method on the target process and return its result. Arguments are automatically coerced to the correct .NET types based on the target method’s parameter signature.
Fully-qualified .NET type name.
Method name, case-sensitive.
Positional arguments. Each value is coerced to the .NET type that matches the method’s parameter signature.
Maximum time to wait for the method to return.
Type Coercion Reference
When callinginvoke(), supply Python values and the SDK maps them to .NET types automatically:
heap_snapshot(*, include_prefix, max_instances, timeout_ms)
Walk the CLR managed heap and return instances of matching types. Each returned object includes the type name and a field-value map.
Filter objects to types whose fully-qualified name starts with this prefix.
Maximum number of object instances to return.
Timeout for the full heap walk, in milliseconds.
