问题
Original Question
(For reproduction instruction see Update II)
I recently messed around with Visual Studio 2019 during a debugging session. I pinned some properties of the class "SqlCommand" as "Favorites". Since that moment I receive an error message "internal error retrieving local value" in the "locals".
There is a "refresh" button on the right of the value column, and when I hit it, I get the message "Internal error in the expression evaluator."
Now I am not able to unpin that specific property, because the class tree can not be opened anymore.
This behavior is not bound to a specific solution, I created a new demo solution where I have the exact same issue.
You can see it in the below screenshot:
The main goal would be to somehow clear the information of which property of the classes are pinned in the "locals" window.
I already tried several things to get rid of the error.
- It seams that VS is somehow storing the information about which properties are tagged, so I tried to delete the "ComponentModelCache" in the AppData.
- I reset the settings.
- I use the repair tool in the installer.
- I deleted the *.suo file, and then I deleted the whole .vs folder.
- I see the same issue when i start devenv in /safemode.
- devenv /resetuserdata did also not help
- I examined the activity log, but there are no clues.
- I changed the Target Framework of the project from 4.7.2 to 3.5
I use Windows Server 2019 Standard, .Net Framework 4.7.2, Visual Studio 2019 16.7.6
I use the following code in the demo application:
private static int Main(string[] args)
{
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
return 0;
}
UPDATE I
This is the pinning feature i'm talking about. I show it on the example of the WorkstationId property of the SqlConnection object (because it on the SqlCommand it does not work anymore). I believe I used it on the command text and the parameters property. The pinnable property is a relatively new feature introduced with 16.4
UPDATE II: Reproduction instruction
- Make a fresh installation of Visual Studio 2019
- Create a new console project
- Use the code that I posted above in the original question
- Set a breakpoint after you created the Command object
- Debug the project [F5]
- Open the "Locals" window.
- Expand the cmd variable and scroll until you find the "Parameters" property
- Pin the parameters property (as described in Update I)
- Stop debugging
- Start the debugger again
- Open the "Locals" window.
- You see the error "internal error retrieving local value"
- Hit the "Refresh" icon (it's the round arrow at the right side of the value column)
- You see the error "Internal error in the expression evaluator" as described in the original question.
UPDATE III (More experiments that did not help)
- I used "fix installation" from the VS installer.
- I uninstalled and reinstalled VS.
- I completely deleted the whole %USER%/AppData/.../VisualStudio folder
回答1:
There is a file called "ObjectFavorites.json" in the folder
%USER%/Documents/Visual Studio 2019/Visualizers
It has the following content
{
"$schema": "https://aka.ms/vs/debugger-managed-favorites-schema",
"types": {
"System.Data.SqlClient.SqlCommand": {
"favorites": [
"Parameters"
]
}
}
}
Delete the line "Parameters".
You don't even have to stop or restart VS, you can edit this file on the fly. Start the debugger again after you have removed the line and the error is gone.
回答2:
In my side, I did not face the same issue.
So maybe you could try the following suggestions:
1) right-lcick on your project Properties--> Build--> Advanced-->--change Debug Info to Full
.
2) check the option Use Managed Compatibility Mode under Tools-->Options-->Debugging-->General
3) enter C:\Users\xxx(current user)\AppData\Local\Microsoft\VisualStudio\16.0_xxx\Settings
open each file and then search for this:
<PropertyValue name="UseVBCSLegacyExpressionEvaluator">0</PropertyValue>
Then, change the value 0
to 1
. Save the change, restart VS to test again. And also you should run it As Administrator.
来源:https://stackoverflow.com/questions/64540926/visual-studio-2019-error-in-locals-panel-during-debugging-internal-error-r