部分作用域内变量出现CS0103错误——.NET Forms调试求助
Visual Studio调试时局部变量无法查看(报CS0103错误)
我维护的一个大型C# Forms应用,在包括VS2022社区版在内的多个Visual Studio版本中均可正常运行。之前调试时,我能通过断点悬停或添加到监视列表的方式查看作用域内的变量值,但现在大部分变量都无法正常查看:悬停时无任何显示,监视列表中直接出现CS0103错误。
比如在代码的if (indexOfItem > -1)行设置断点后,仅regex_MatchNameForDirectory、SectionInfos、comboBox_Sections及comboBox_Sections.SelectedIndex能正常查看,其余变量(如m、sectionKey、nameInComboBox、indexOfItem)均无法查看,但代码本身运行完全正常。
我不清楚问题何时出现,推测是Visual Studio更新或配置变更导致的。已经在网络及相关平台搜索过该问题,但未找到有效解决办法。
Match m = regex_MatchNameForDirectory.Match(Settings.Default.SelectedSection); if (m.Success) { string sectionKey = m.Groups["sectionID"].Value; if (SectionInfos.ContainsKey(sectionKey)) { string nameInComboBox = SectionInfos[sectionKey].NameForDirectory; int indexOfItem = comboBox_Sections.FindStringExact(nameInComboBox); if (indexOfItem > -1) comboBox_Sections.SelectedIndex = indexOfItem; } }
内容的提问来源于stack exchange,提问作者BenevolentDeity
相关产品推荐
相关产品推荐

