Ara
Download

Search or run a command

Jump to a section or open an Ara link.

Diagnostic code · ARA0400

NativeAOT unsafe API

The module uses an API that needs runtime code generation, dynamic loading or reflection unavailable or unsafe under NativeAOT and trimming. This is a compilation error even when developing with the JIT; the last good code keeps running.

Common causes

  • Calling Assembly.Load, using AssemblyLoadContext or Reflection.Emit, or compiling expression trees.
  • Looking up types or members by name, invoking methods reflectively, constructing runtime generic types, or using Activator.CreateInstance(Type).
  • Using dynamic invocation, member access or construction.

Fixes

  • Replace runtime discovery and invocation with generated registration, serialization and direct typed calls.

  • Use statically referenced types and explicit factories instead of loading or constructing code dynamically.

  • Code: ARA0400

  • Constant: cs::AOT_UNSAFE

  • Reported by: Ara.Analyzers