ActivatorUtilities.CreateInstance replacment for native AOT
as in title, how can i replace ActivatorUtilities.CreateInstance function? right now it complain that:
3 Replies
NativeAOT prevents reflection from being used.
this is not true
to be clear,
ActivatorUtilities.CreateInstance
, and most of dependency injection in general, should be fully functional in NativeAOT
you need to be using .NET 8 (and 8.0 versions of MS.Extensions libraries) though
and you need to ensure you don't have other AOT or trimming warnings at build time which could be contributing to thislet me check
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
updated to 8.0.0, also project is .net8