Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017 not highlighting errors

I recently upgraded from Visual Studio 2012 to 2017 (updated to version 15.3.5) and have some issues with the IDE.

In a certain project, I don't get error underlining.

enter image description here

and in the Error List pane, "Build Only" actually shows more information than "Build + IntelliSense"

enter image description here

Also, with "Build + IntelliSense" selected, I can only see the compiler error in the Output window. Here is the error list after a failed build

enter image description here

but the output window has this:

3>------ Build started: Project: ..., Configuration: Debug Any CPU ------
3>C:\Checkout...\MainForm.vb(454,27): error BC30311: Value of type 'Module1.aClass' cannot be converted to 'Module1.bClass'.

This doesn't happen on all projects. I made a new project to see if I could reproduce, and I can't. Here is a new project with the same code, where the error is underlined in code and "Build + IntelliSense" works.

enter image description here

I have even sorted the xml in the vbproj files and "diffed" the offending project vs the new project, and there is no obvious difference which would cause this. Both reference the same compiler. Both projects target .Net 4.6.2 and are set to compile for x86 only. The offending project references a few other projects (C# and VB.Net) plus a third party dll and a nuget package. Aside from these differences there is nothing else.

Other projects (C# and VB.Net) in the offending project's solution work fine.

I have seen similar issues talked about online but no fixes have worked for me. I have tried the "Repair" option in the installer. I then uninstalled Visual Studio and reinstalled.

Update:

Changing the target framework seems to have some effect. A project with this behavior was targeting 4.6.2 and showing no errors, and when it was changed to 4.7, it showed a compile error. Then changing back to 4.5 it showed an error. Then changing back to 4.6.2 it showed no errors. Repeating the process proved to be non repeatable. 4.7, 4.5, 4.6, 4.6.2 - whatever, now all show no errors.

It's also important to link this Microsoft page https://developercommunity.visualstudio.com/content/problem/7759/no-errors-displayed-in-the-error-list.html as many other people seem to have a similar issue.

like image 367
djv Avatar asked Oct 05 '17 18:10

djv


People also ask

Why is Visual Studio not showing errors?

Please check the option “Always show error list if build finishes with errors” under Tools > Options > Projects and Solutions > General . Then, delete the hidden . vs folder in the project folder and re-launch your Visual Studio to try again.

How do I enable error highlighting in Visual Studio?

Before that make sure that you're in a C++ file. Then, go to the command palette (Ctrl + Shift + P) and search for "error." Click on the "Enable Error Squiggles" option. That's it.

How do I get Visual Studio to show errors?

To display the Error List, choose View > Error List, or press Ctrl+\+E.

Why is my VS code not showing errors?

This is because the C/C++ IntelliSense, debugging, and code browsing extension does not know about the current project. Navigate to View | Command Palette, enter and select C/C++ Build and debug active file: Select Project, and then select the correct project that you want to work with.


1 Answers

I have solved the problem, at least in my solution.

I was playing around with project references, and found that when a particular project was not referenced by another project, I got error underlining. I went through a process of changing framework version targets until something worked.

All my projects had previously been targeting .NET 4.6.2. By targeting 4.7 on all the projects, I now get proper error underlining and reporting in the Error window.

I'm not sure if this is a solution for everyone and it will take some additional work on my end to deploy my project to production but I can accept this.

I guess this is related to targeting 4.6.2 using Visual Studio 2012 and upgrading to 2017. Maybe something was not set properly if/when the projects were upgraded.

like image 194
djv Avatar answered Sep 28 '22 02:09

djv