It would seems like this breaking change break you program:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/9.0/cet-support
The doc says to add this <CETCompat>false</CETCompat> to .csproj should fix it
<CETCompat>false</CETCompat>
.csproj