We need to set the System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported feature to false when using FullAOT (i.e. AOT + no interpreter).
This is done by setting the DynamicCodeSupport property to false:
https://github.com/dotnet/sdk/blob/9ca8336afab6247a22e745c2de4960e9b660d164/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L529-L532
The NativeAOT compiler does that here:
https://github.com/dotnet/sdk/blob/9ca8336afab6247a22e745c2de4960e9b660d164/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L27
We need to do the same when using MonoAOT + no interpreter.