当前位置:网站首页>Rider调试ASP.NET Core时报thread not gc-safe的解决方法
Rider调试ASP.NET Core时报thread not gc-safe的解决方法
2022-08-10 20:31:00 【阿升】
新建了一个ASP.NET Core 5.0的Web API项目,当使用断点调试Host.CreateDefaultBuilder(args)时,进入该函数后查看中间变量的值,报错Evaluation is not allowed: The thread is not at a GC-safe point
。在群里问了也没人回应,可能没有遇到过这个问题吧。
一.解决问题的过程
1.Visual Studio 2022调试
首先想到的是可能Rider不行,换成Visual Studio 2022试试,所以就查到了文献[1],发现需要pdb文件,还需要设置符号什么的,觉得太麻烦了。
2.Rider调试
然后又换成了Rider,既然调试看不到中间变量的值,那就直接Console.WriteLine()出来,结果Console在当前上下文中根本就不存在,如下:
二.最终的解决方法
1.YouTrack上的解决方法
继续在网上查找,发现在JetBrains的官方YouTrack上[2][3],Evgeny Terekhin在2022年5月30日给出了一个解决方法:
SET COMPLUS_ZapDisable=1 NGen off (CLR)
SET COMPLUS_JitMinOpts=1 Disable as much JIT optimizations as possible (CoreCLR)
SET COMPlus_TieredCompilation=0 No tiered JIT, only do one pass (CoreCLR)
SET COMPLUS_ReadyToRun=0 Don't do netcore's analog to NGen (CoreCLR)
大概的意思是对CLR做了设置,先不管设置的什么了,抱着试试看的心态。配置launchSettings.json文件:
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"COMPLUS_ZapDisable": "1",
"COMPLUS_JitMinOpts": "1",
"COMPlus_TieredCompilation": "0",
"COMPLUS_ReadyToRun": "0"
}
完成的配置文件如下所示:
2.调试ASP.NET Core
打上断点启动调试后,神奇般的发现也可以查看中间变量了。如下: Rider调试源码还是比Visual Studio方便很多,不需要pdb文件,也不需要设置什么符号,只需要进入要调试的函数中打上断点,然后启动调试即可。
参考文献:
[1]Debugging External Sources with Visual Studio:https://devblogs.microsoft.com/visualstudio/debugging-external-sources-with-visual-studio/
[2]Debugger: Evaluation is not allowed: The thread is not at a GC-safe point:https://youtrack.jetbrains.com/issue/RIDER-40357
[3]When debugging, variables don't display all of their data, instead we get 'Evaluation is not allowed: The thread is not at a GC-safe point':https://youtrack.jetbrains.com/issue/RIDER-10885/When-debugging-variables-dont-display-all-of-their-data-instead-we-get-Evaluation-is-not-allowed-The-thread-is-not-at-a-GC-safe
边栏推荐
- [SemiDrive source code analysis] [MailBox inter-core communication] 52 - DCF Notify implementation principle analysis and code combat
- 设备管理中数据聚类处理
- C 语言 时间函数使用技巧(汇总)
- Leetcode 200.岛屿数量 BFS
- [SemiDrive source code analysis] [MailBox inter-core communication] 51 - DCF_IPCC_Property implementation principle analysis and code combat
- 多功能纳米酶Ag/PANI|柔性衬底纳米ZnO酶|铑片纳米酶|Ag-Rh合金纳米颗粒纳米酶|铱钌合金/氧化铱仿生纳米酶
- C语言系列——猜名次、猜凶手、打印杨辉三角
- Apple Font Lookup
- 关于 NFT 版权保护的争议
- 用汇编带你看Golang里到底有没有值类型、引用类型
猜你喜欢
【nvm】【node多版本管理工具】使用说明和踩坑(exit status 1)
npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead.
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Are you hungry - Institution tree radio
svg+元素js实现在图片上描点成框,并获取相对图片的坐标位置
leetcode 84.柱状图中最大的矩形 单调栈应用
leetcode 85.最大矩形 单调栈应用
深度学习实战教程(一):感知器
[SWPUCTF 2021 新生赛] web
mysql踩坑----case when then用法
随机推荐
XML小讲
(十二)STM32——NVIC中断优先级管理
设备管理中数据聚类处理
电信保温杯笔记——《统计学习方法(第二版)——李航》第17章 潜在语义分析
【语义分割】2017-PSPNet CVPR
一次由groovy引起的fullGC问题排查
TortoiseSVN小乌龟的使用
PostgreSQL — Installation and Common Commands
redis如何查看key的有效期
什么是抽象类?什么时候用?什么是接口?抽象类与接口的区别?
工程师应该怎么学习
优雅退出在Golang中的实现
多功能纳米酶Ag/PANI|柔性衬底纳米ZnO酶|铑片纳米酶|Ag-Rh合金纳米颗粒纳米酶|铱钌合金/氧化铱仿生纳米酶
@Autowired注解 --required a single bean, but 2 were found出现的原因以及解决方法
Auto.js中APP应用相关指令
验证码倒计时自定义hooks
【语义分割】2016-SegNet TPAMI
爱丁堡大学最新《因果机器学习: 医疗健康与精准医疗应用》2022综述
Getting started with kuberentes Auditing
Ferritin particle-loaded raltitrexed/pemetrexed/sulfadesoxine/adamantane (scientific research reagent)