Visual Studio compiles fine, but it still shows red lines
Solution 1
Delete the contents of the temporary ASP.NET folder and then rebuild. It'll either be in your user folder (for IIS Express - \AppData\Local\Temp\Temporary ASP.NET Files) or the Windows directory (for IIS - C:\Windows\Microsoft.Net\Framework\vx.xx\Temporary ASP.NET Files)
Paths are off the top of my head and may not be correct
Solution 2
Visual Studio 2017:
Closing Visual Studio and removing the .vs
folder located in the solution directory worked for me.
This folder has a hidden
attribute. You may need to change settings in folder options to show hidden files.
Solution 3
For me, this issue got fixed when I unloaded and reloaded the project again.
Solution 4
I had this issue and it was related to ReSharper.
Solution steps for me:
Disable ReSharper
VisualStudio\Tools\Options\ReSharper Ultimate\General\Suspend Now
Build Solution
(Ctrl + Shift + B)
Re-enable ReSharper
VisualStudio\Tools\Options\ReSharper Ultimate\General\Resume Now
Solution 5
Just had this problem while working with a solution created in Visual Studio 2012 but running in 2013. I closed Visual Studio, deleted all \bin and \obj directories and the problem was gone.
Related videos on Youtube
Lost
Updated on January 21, 2022Comments
-
Lost over 2 years
I am using Visual Studio 2012 and it was working all fine until I started observing some funny behavior. When I open my code it shows red Underlines which we usually see when there is an error in our code. Surprisingly, the code compiles all fine. I have made following observations that are not normal at all.
- Red underlines in the code
- While cleaning or building the solution no error.
- Red underlines go away for some time after I build/clean the solution, but they come back eventually.
- Because of this, my IntelliSense stopped working.
- I can not right click on any component and go to its definition.
Any ideas?
-
matth over 10 yearsWhat code is showing underlines? Can you provide examples?
-
Max over 10 yearsAre you perhaps running old code? Try a small implementation that shows something, if nothing happens you might be running old code.
-
AlG over 10 yearsAre you running Reshaper or any other tool that may be doing the underlines?
-
Pierre-Luc Pineault over 10 yearsIs this on all code files? It happened to me once when I opened a file which was not from my solution, not being able to go to the definition gave it away for me.
-
Oleg Kyrylchuk over 9 yearsI was using Resharper. You can disable ReSharper by using the Suspend button in menu Tools -> Options -> ReSharper. Then Resume it, it helped me.
-
Kyle almost 9 yearsAlternatively, if this is just affecting the one project/solution and you're using git with the appropriate ignores in place for temporary files, try commiting you changes, deleting your working copy and force checkout your branch.
-
Sнаđошƒаӽ over 7 yearsI don't see a solution in your answer. "It seemed intellisense was not able to resolved dependencies on its own..." - are you saying by "browsing through the classes, structures" you helped intellisense resolve the dependencies?
-
Robert Columbia over 7 years@Sнаđошƒаӽ I think that is exactly what he is saying.
-
Sнаđошƒаӽ over 7 years@RobertColumbia No offence to OP, but I think that's just ridiculous.
-
Robert Columbia over 7 years@Sнаđошƒаӽ well that is what he is saying. If you think that strategy is not helpful, downvote the answer.
-
irsis over 7 years@Sнаđошƒаӽ Well, I reached to post because I was also facing the same problem. First I tried all the answers before I posted what worked for me Like others also have answered based on there experience. I don't see anything wrong with it. Instead, it might help someone else too.
-
nico over 6 yearsI was facing the same issue and this was the only way it got fixed. After VS indexing was done, none of the includes could be resolved. Then I start opening some files and VS seemed to find the correct location for the classes I was working on. As a side note, I was working on a big project structured with CMAKE.
-
secretwep over 6 yearsFor VS 2017, this solution worked where none of the others on this page did (like cleaning temp folders and cleaning /bin and /obj). The .vs wasn't "hidden" on my system as mentioned (whereas e.g. my .git folder was of course, so I could tell the difference).
-
Lost over 6 yearswhat if the error is in Visual studio for Mac? what would be the path for this folder?
-
Alx about 6 yearsRemoving the just the .suo file (which is in the .vs folder) also works
-
MusicAndCode almost 6 yearsI needed to close and open VS after and it works. Thanks
-
Amit Kulat over 5 yearsI tried deleting the .suo file but it gets recreated again when I restart VS 2017
-
VeganHunter over 5 years@AmitKulat Yes, .suo file is a structured storage that is created by Visual Studio and it contains a bunch of settings. Due to some bug it stops working properly. So, when you remove it, it will be recreated with correct default settings.
-
Alex Fainshtein over 5 years@AmitKulat Very often deleting .suo is enough, but not always. Deleting the whole .vs (containing .suo) is more "potent". And yes, .vs will be recreated when you reopen the solution.
-
nilsK over 5 yearsThe 'Clear cache' button on the Environment | General page of ReSharper options solved my problem. Thanks for the hint though!
-
Bob Stein about 5 years“Unsupported ... This version of Visual Studio is unable to open the following projects...” — a rather heart-stopping popup after deleting the .vs directory. But it appears benign. Clicked OK and the solution opened anyway, after a Migration Report. This may be an unrelated issue that was dormant until .vs was deleted. Reporting here for posterity.
-
Albert Romkes about 5 yearsThis also works for Visual Studio 2019 (Preview. Deleting the .vs folder)
-
Nandolcs about 5 yearsAfter days of research, unload/load projects and many .vs folder removals, this was the root cause of my problem so I consider this a valid answer. May someone, somewhere bless you my son.
-
DKR about 5 yearsperfect solution
-
Muhammad Saqib about 5 yearsWorked for me. Yes. ReSharper was the problem.
-
Lemonseed almost 5 yearsI had the same/similar problem. One class that was clearly in the project, but Visual Studio would not recognize with color-coding, and each reference to it showed up as an error (even though compiled fine). Deleting the hidden
.vs
folder did the trick. -
bahramzy about 3 yearsSuspend Now solves the issue. Resume Now - the issue is there again.
-
TRPh about 3 yearsAfter I did this, the code wouldn't compile. Visual Studio 2017 seemed to have forgotten it was in C++17 mode, even though C++17 was still selected.
-
Harshan almost 3 yearsClose VS and delete .VS folder worked for me too. I'm using mac m1 with Visual Studio 2019.
-
Peter Mortensen almost 3 yearsHow many files did you have to add to the new Solution file?
-
Peter Mortensen almost 3 yearsHow exactly? Refresh in what sense? Can you add instructions to your answer (a how-to)? But without "Edit:", "Update:", or similar - the answer should appear as if it was written today.
-
Peter Mortensen almost 3 yearsCan you be more specific than "do a rebuild all" and "do a clean"? Exactly how should it be done? Can you add the exact menu commands, etc. that should be invoked (or at least provide some hints)? But without "Edit:", "Update:", or similar - the answer should appear as if it was written today.
-
HardcoreGameDev over 2 yearsConsider reading others' answers in an old post. You can just upvote this answer, this is the Stack Overflow way of saying thank you. Instead of posting a duplicate.
-
Nickson Yap over 2 yearsThis is very likely a Visual Studio Code command, not Visual Studio
-
Dave Stuart over 2 yearsWindows 10 with Visual Studio 2019. Deleting the .vs folder worked for me! Thanks!
-
NJS about 2 yearsIf resuming ReSharper causes the issue to reappear, you may need to upgrade to a newer version of ReSharper. Older versions simply don't support newer C# features
-
Octopus almost 2 yearsSeems like it momentarily, but if you wait a few minutes all the squiggles will come back.