icsharpcode/ILSpy · error · InvalidDataException
BAML defer record points at an offset that is not a record b
Error message
BAML defer record points at an offset that is not a record boundary.
What it means
Thrown during the second pass of BamlReader.ReadDocument, when resolving IBamlDeferRecord entries (e.g. DeferableContentStart). A defer record references a stream offset that is not present in the map of record start positions, so the deferred content cannot be linked. InvalidDataException signals corrupt or internally inconsistent BAML.
Source
Thrown at ICSharpCode.BamlDecompiler/Baml/BamlReader.cs:273
case BamlRecordType.EndAttributes:
case BamlRecordType.DefTag:
case BamlRecordType.ClrEvent:
case BamlRecordType.Comment:
default:
throw new NotSupportedException();
}
rec.Position = pos;
rec.Read(reader);
ret.Add(rec);
recs.Add(pos, rec);
}
for (int i = 0; i < ret.Count; i++)
{
if (ret[i] is IBamlDeferRecord defer)
defer.ReadDefer(ret, i, offset => recs.TryGetValue(offset, out var rec)
? rec
: throw new InvalidDataException("BAML defer record points at an offset that is not a record boundary."));
}
return ret;
}
}
}View on GitHub (pinned to 60c08fcb74)
Solutions
- Re-extract the BAML resource from a known-good assembly.
- Treat the resource as corrupt and skip it.
- Report the failing offset for diagnosis.
Defensive patterns
Strategy: try-catch
Try / catch
try {
var doc = BamlReader.ReadDocument(stream, token);
} catch (InvalidDataException ex) when (ex.Message.Contains("record boundary")) {
// deferable content references a bad offset; BAML is corrupt
} Prevention
- Do not retry parsing a corrupt stream unchanged; re-obtain the resource.
When it happens
Trigger: A DeferableContentStart record (or similar) points at an offset that is mid-record or beyond the stream, so recs.TryGetValue(offset) fails. Caused by corrupted/truncated BAML or a malformed deferable-content section.
Common situations: Truncated BAML resource; bit-flipped offset field; BAML assembled by a broken tool.
Related errors
AI-assisted analysis of icsharpcode/ILSpy@60c08fcb74 (2026-08-13).
Data as JSON: /api/errors/fad3036ae570593d.
Report an issue: GitHub.