Search code examples
c#visual-studiounity-game-engine

Visual Studio does not show errors in the code anymore


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! :)


Solution

  • 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.