You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部分作用域内变量出现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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 10:10:49