Visual Studio does not show errors in the code anymore

Viewed 17815

I've been using Visual Studio (2017) for quite a long time now, to program mostly in C#, for Unity games. Recently though, I noticed that it was not displaying any errors in the code anymore, or at least most of them. I initially started making some small tests, for example removing variables that were being used multiple times in the scripts. Visual Studio was not showing any errors, while when going back to Unity, it was showing all the correct errors in the console (as always). Instead, if I tried to remove a parenthese, it was, after a bit, showing errors all over the place. Again, it was really strange.

After one day, I was still testing, and I noticed that if I first opened Visual Studio, and then in "recent" I clicked on the the .sln file, that opened all the scripts for one Unity project, it was immediately showing all the right errors, like it had always done and how (I think) it should always do. I started looking for some differences between what I was seeing there, and what I was seeing when opening the .cs files (in the way that wasn't working):

  • At the top, I wasn't seeing "Debug" and "Any CPU" how I was when it was working:

enter image description here enter image description here

  • Another thing was that, between the "Project" and the "Debug" buttons (at the top, that open the drop-down lists), I didn't have the "Compile" button.

  • Also, under the the "Debug" drop-down many options like "start debug" were not available / disabled.

  • At the top left, under the left-most script name, I have "External files" instead of "Assembly-CSharp"

  • At the right of where there should be "Debug" and "Any CPU", I have "Connect" instead of "Start" (Or something similar, my system's language is not english, these are translations)

Another (maybe less relevant) thing that has changed from before, when it was working:

  • I have installed Visual Studio 2019, and uninstalled after a few minutes (I've always preferred Visual Studio 2017!).

Programming without seeing the errors realtime takes much more time, so I'd really like to fix this problem, if it is possible to do so. Is there anything that I have to activate? Did I accidentally press a combination of keys?

Thanks in advance! :)

9 Answers

Deleting the .suo file might help when encountering erratic Visual Studio behavior.

The file contains user defined solution settings, including breakpoints, debug options, bookmarks and may get corrupted or saved in an undesired state.

If you delete it, a new .suo file will be created once you reopen the solution in Visual Studio.

Just open the error list form View -> Error List or use the shortcut Ctrl + \ , E

enter image description here

You need to turn on the underline errors in the editor options in Visual Studio.

These options can be found here:

Tools > Options > Text Editor > C# > Advanced > Editor Help

I had this problem also. For me it was caused by opening the project instead of the solution. When I opened the solution (.sln file), all the editor features started working.

I had this issue for a while and it had to do with my solution. I went to my project, ran a code analysis on it, then I re-targeted it to an older version.

I have no idea why this worked, however it fixed the issue.

Try deleting the bin folder in the project directory, this will force the code to be recompiled.

Just make sure to save any .dll files in the bin folder that may have been added manually. You can see these in References in Solution Explorer, and add them back after.

Visual Studio will re-create the bin folder, don't worry!

I had the same problem in VS 2022 Preview version.

The solution was to check: Tools -> Options -> Text Editor -> General -> Show error squiggles

Options dialog

Go to setting, type Error Squiggles in the search setting and then enable it.

For me it was a file that was not included in the project.

After switching some branches a newly created file stopped being included in the project and was not being read for errors. I had to click "Show All Files" on solution explorer, right click the file and select "Include in project".

Related