Skip to main content
Version: dev

Troubleshooting

This page covers common C# runtime issues and fixes.

TypeNotRegisteredException

Symptom: Type not registered: ...

Cause: A user type was serialized/deserialized without registration.

Fix:

Fory fory = Fory.Builder().Build();
fory.Register<MyType>(100);

Ensure the same type-ID/name mapping exists on both write and read sides.

InvalidDataException: xlang bitmap mismatch

Cause: The payload is not an xlang Fory frame, or it came from a peer/runtime mode that does not emit the xlang header C# requires.

Fix: Ensure the payload was produced by an xlang-compatible Fory runtime. C# always expects the xlang header and does not expose a separate Xlang(...) builder option.

Fory writer = Fory.Builder().Compatible(true).Build();
Fory reader = Fory.Builder().Compatible(true).Build();

Schema Version Mismatch in Strict Mode

Symptom: InvalidDataException while deserializing generated struct types.

Cause: Compatible(false) with CheckStructVersion(true) enforces exact schema hashes.

Fix options:

  • Enable Compatible(true) for schema evolution.
  • Keep writer/reader model definitions in sync.

Circular Reference Failures

Symptom: Stack overflow-like recursion or graph reconstruction issues.

Cause: Cyclic graphs with TrackRef(false).

Fix:

Fory fory = Fory.Builder().TrackRef(true).Build();

Concurrency Issues

Cause: Sharing a single Fory instance across threads.

Fix: Use BuildThreadSafe().

Validation Commands

Run C# tests from repo root:

cd csharp
dotnet test Fory.sln -c Release