csharp
AOT type initializer exception
type initializer.*threw.*AOT|TypeLoadException.*AOT
Fixes
- 1.Move init out of static constructors
- 2.Use Lazy<T> for deferred init
- 3.Add [ModuleInitializer]
dotnetaotinitialization
Related Errors
csharp3 fixes
AOT unsupported type usage
Type '.*' is not supported by the AOT compiler
- •Replace with AOT-compatible type
- •Add [DynamicallyAccessedMembers] attribute
csharp3 fixes
Trimming unsafe code detected
Trim analysis warning IL2026.*RequiresUnreferencedCode
- •Add [UnconditionalSuppressMessage]
- •Replace reflection with source generators
csharp3 fixes
Minimal API DI failure
No service for type '.*' has been registered
- •Register service in Program.cs
- •Check service lifetime