调试时的监视窗口:CS0103:当前上下文中不存在名称“

2024-04-25

我正在使用:

Visual Studio Community 2022 (64-bit), Version 17.4.2 with

.NET Framework, Version 4.8.09032.

昨天,2022 年 2 月 12 日有更新,我是通过“Visual Studio 安装程序”安装的。

此后,我在调试时无法在“观察”窗口中观察局部变量。它给了我一个 CS0103 错误(见下图)。

同样在“本地”窗口中,它们也不会出现。

(edit: 已经贴出代码了StringParser here 监视窗口 CS0103 - 跟进以排除我的代码问题 https://stackoverflow.com/questions/74694938/watch-window-cs0103-follow-up-to-exclude-my-code-as-problem)


解决方案非常简单,它由两个项目组成:

Windows Forms App (.NET Framework)

Windows Forms Control Library (.NET Framework)

后者当然与第一个相关。控制库包含StringParser.


基本上,接下来的代码是所有表单项目。这只是创建时的测试代码StringParser。在更新之前,这工作得很好,就像有parser作为全球的Form1.

声明局部变量时parser并将其实例化为 Form1 的全局,没有CS0103在那个变量上。


接下来的两个问题解决了这个问题。

VS 2015 Update 2 - 调试时变量不存在,为什么? https://stackoverflow.com/questions/36463286/vs-2015-update-2-variable-does-not-exist-when-debugging-why

在 Visual Studio 2019 中调试大多数变量时出现错误 CS0103 https://stackoverflow.com/questions/58397723/error-cs0103-when-debugging-most-variables-in-visual-studio-2019

虽然我怀疑第一个确实描述了我的情况。尚未尝试该解决方案,因为它是不同的版本。

第二个没有解决这个问题。


public Form1()
{

    InitializeComponent();

    StringParser parser = new StringParser();
    parser.Content = filecontent;

    string token = "";
    while (!parser.Next('<'))
    {
                
        parser.Next('>');
        token = parser.Token;

    }

}

这是一个回归17.4 V.S.
WinForms 存储库问题:https://github.com/dotnet/winforms/issues/8354 https://github.com/dotnet/winforms/issues/8354
罗斯林回购问题:https://github.com/dotnet/roslyn/issues/66109 https://github.com/dotnet/roslyn/issues/66109


17.4 中已修复。5.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

调试时的监视窗口:CS0103:当前上下文中不存在名称“” 的相关文章

随机推荐