Visual Studio 2019: Error in “locals” panel during debugging - “internal error retrieving local value”

∥☆過路亽.° 提交于 2021-01-29 18:13:30

问题


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

  1. Make a fresh installation of Visual Studio 2019
  2. Create a new console project
  3. Use the code that I posted above in the original question
  4. Set a breakpoint after you created the Command object
  5. Debug the project [F5]
  6. Open the "Locals" window.
  7. Expand the cmd variable and scroll until you find the "Parameters" property
  8. Pin the parameters property (as described in Update I)
  9. Stop debugging
  10. Start the debugger again
  11. Open the "Locals" window.
  12. You see the error "internal error retrieving local value"
  13. Hit the "Refresh" icon (it's the round arrow at the right side of the value column)
  14. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!