问题:在运行.net 9程序时显示错误:
CLR: Assert failure(PID 2404 [0x00000964], Thread: 14732 [0x398c]): !AreShadowStacksEnabled() || UseSpecialUserModeApc()
File: D:\a\_work\1\s\src\coreclr\vm\threads.cpp:7938 Image:
D:\Working\TestQJSharp\TestQJSharp\bin\Debug\net9.0\TestQJSharp.exe
解决:在项目的配置中添加一个配置即可:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<CETCompat>false</CETCompat><!--增加这个配置-->
</PropertyGroup>
在PropertyGroup节点中增加<CETCompat>false</CETCompat>配置,重新生成程序即可。
这个问题在.net9上才会出现,在其它.net版本我是没有遇到过。