Am using:
Visual Studio Community 2022 (64-bit), Version 17.4.2
with
.NET Framework, Version 4.8.09032.
There was an update yesterday, 02-12-2022, with I installed through the ‘Visual Studio Installer’.
After this I can’t watch local variables in the ‘Watch’ window while debugging. It gives me a CS0103 error (see image below).
Also in the window ‘Locals’ they do not appear.
(edit: Have posted the code of StringParser
here Watch window CS0103 – follow up to exclude my code as problem)
The solution is very simple, it consists out of two projects:
Windows Forms App (.NET Framework)
Windows Forms Control Library (.NET Framework)
The latter is linked to the first ofcourse. The control library contains StringParser
.
Basically, the next code is all of the forms project. It is just test code while creating the StringParser
. Prior to the update, this worked fine, as is when having parser
as global of the Form1
.
When declaring the local variable parser
and instantiating it as global of the Form1, there is no CS0103
on that variable.
The next two questions adresses this problem.
VS 2015 Update 2 – Variable does not exist when debugging, why?
Error CS0103 when debugging most variables in Visual Studio 2019
While I suspect the first does describe my situation. Haven’t tried the solution as it is a different version.
The second does not adress this issue.
public Form1()
{
InitializeComponent();
StringParser parser = new StringParser();
parser.Content = filecontent;
string token = "";
while (!parser.Next('<'))
{
parser.Next('>');
token = parser.Token;
}
}
2
Answers
I cannot reproduce this error according to the code. Maybe you can provide more information about
StringParser
to help us reproduce the problem and give more suggestions.You can try to Refresh watch values:
select the refresh icon, or press the spacebar or you can select Enable property evaluation and other implicit function calls in Tools > Options > Debugging > General and try again.
If they don’t work you can report this on DC.
And if you want to rollback to the vs used before you can choose more > Rollback to previous version in vs installer:
It’s a regression in
17.4
V.S.WinForms repo issue: https://github.com/dotnet/winforms/issues/8354
Roslyn repo issue: https://github.com/dotnet/roslyn/issues/66109
Fixed in 17.4.5.