Incompatible .NET API reference
Understand which .NET APIs are incompatible with Unity's assembly loading and management system, and which compatible alternatives you can use instead.
Read time 2 minutesLast updated 16 days ago
Unity's runtime uses a specialized assembly loading and management system to support code reload. The UAC (Unity API Compatibility) analyzer flags several reflection APIs that are or will soon become incompatible with Unity's assembly lifecycle.
Warning code | Incompatible .NET API | Compatible Unity alternative |
|---|---|---|
| This standard .NET API returns all loaded assemblies from all AssemblyLoadContexts (ALCs), including those that are in an unloading state. Using these stale assembly references can cause | |
| Certain methods and events in the These | Unity's LifeCycle APIs. |
| Unity loads many assemblies from memory streams rather than directly from disk to avoid file locking. For these assemblies, the | |
| These methods load assemblies outside of Unity's assembly management system. This bypasses Unity's dependency tracking, prevents proper unloading during script recompilation and code reloads, and can cause assembly version conflicts. Use | |
| This serializer is deprecated in modern .NET due to critical security vulnerabilities and will not be supported in Unity's runtime environment. Use Unity's built-in serialization system, | Unity serialization, |
Code transition example
The following table provides examples of incompatible code snippets and what they can be replaced with:
Incompatible code | Replacement | Namespace |
|---|---|---|
| | |
| | |
| | |
| | |