Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't see values while debugging

I'm using Visual Studio 2015, and when I hit a breakpoint, I cannot get any info on the values of variables.

  • When hovering over a variable, nothing comes up.
  • In Immediate Window or Watches, I get:

    error CS0648: '' is a type not supported by the language
    

This happened all of a sudden, as it used to work until yesterday.

I've tried a few things including resetting all user settings, deleting *.user files, restarting Visual Studio, and even restarting Windows.

What else can I try?

Update: I've written a blog post about this problem and how to reproduce it.

like image 343
Gigi Avatar asked Sep 02 '15 09:09

Gigi


People also ask

How do I view variables in debugging?

The most commonly used way to look at variables is the DataTip. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable.

How can I see data table values while debugging in Visual Studio?

set the break point on the dataset/datatable(f9 shortcut key for break point) and run your application (f5 is the shortcutkey ) When the break point comes mouse hover the dataset/datatable click on the glass shown in the hover image in visual studio . Note : check compilation debug="true" is true in web config .


2 Answers

You won't believe this but it seems that this is somehow related to a const expression I had. Removing const and using a variable solved the problem.

How weird. Didn't manage to reproduce on a simple console application. The problem originally occurred on an ASP .NET 5 Web Application.

Update: see more details in my blog post which also explains how to reproduce the issue.

like image 65
Gigi Avatar answered Oct 21 '22 02:10

Gigi


This is a bug currently being tracked by aspnet/Home issue #955.

Console Application repro for reference:

REPRO

  1. Open VS2015 (Windows 10, ASP.NET 5 Beta 7)
  2. Click File > New > Project > Web > Console Application (Package) > Ok
  3. Edit Program.cs to reflect code snippet below.
  4. Add a breakkpoint just after Console.WriteLine(a);
  5. Run the project
  6. Right-click variables a and b click Add Watch

CODE

public void Main(string[] args)
{
    const int a = 3;
    int b = 4;
    Console.WriteLine(a);
}

EXPECTED

Watch window displays values for variables a and b

ACTUAL

Watch window Value column for variables a and b displays:

error CS0648: '' is a type not supported by the language

NOTES

  1. The value of a is written correctly to Console
  2. Removing const from the snippet reverts to EXPECTED bevahiour
like image 36
Stafford Williams Avatar answered Oct 21 '22 03:10

Stafford Williams