Quick answer: Godot 4 C# Web/Mobile builds throwing TypeLoadException at runtime? Trimming removed reflectively-used types - add DynamicallyAccessedMembers attribute or set trimmer config.

AOT-trimmed iOS build crashes when JSON deserializer reflects into a type. PC build works.

Annotate types

[DynamicallyAccessedMembers(
  DynamicallyAccessedMemberTypes.All)]
public class SaveData {}

Trimmer reserves the type from removal.

Use a trimmer config

linker.xml with explicit preserve rules. Heavier setup; works for code you can't annotate (3rd party).

Switch to source generators

System.Text.Json source generators bake the deserializer at compile time. No reflection; no trim risk.

“AOT trimming and reflection are at war. Annotations are the truce.”

When you migrate to AOT, audit JSON serializers, dependency injection, and any reflection-based config. The class of bug surfaces all at once.