147

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.

  1. Red underlines in the code
  2. While cleaning or building the solution no error.
  3. Red underlines go away for some time after I build/clean the solution, but they come back eventually.
  4. Because of this, my IntelliSense stopped working.
  5. I can not right click on any component and go to its definition.

Any ideas?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lost
  • 12,007
  • 32
  • 121
  • 193
  • What code is showing underlines? Can you provide examples? – matth Jan 13 '14 at 18:13
  • Are you perhaps running old code? Try a small implementation that shows something, if nothing happens you might be running old code. – Max Jan 13 '14 at 18:13
  • Are you running Reshaper or any other tool that may be doing the underlines? – AlG Jan 13 '14 at 18:14
  • Is 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. – Pierre-Luc Pineault Jan 13 '14 at 18:14

28 Answers28

251

Visual Studio 2017, Visual Studio 2019, Visual Studio 2022:

Closing Visual Studio and removing the .vs folder located in the solution directory worked for my C# projects.

This folder has a hidden attribute. You may need to change View settings to show hidden files in File Explorer.

VeganHunter
  • 5,584
  • 2
  • 26
  • 26
  • 3
    For 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). – secretwep Oct 31 '17 at 02:08
  • Removing the just the .suo file (which is in the .vs folder) also works – Alx Apr 26 '18 at 09:51
  • 1
    I tried deleting the .suo file but it gets recreated again when I restart VS 2017 – Amit Kulat Sep 19 '18 at 14:17
  • 3
    @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. – VeganHunter Sep 20 '18 at 23:03
  • 1
    @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. – Alex Fainshtein Dec 23 '18 at 09:17
  • 5
    **“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. – Bob Stein Feb 07 '19 at 16:44
  • 1
    I 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. – Lemonseed Jun 21 '19 at 20:08
  • After 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. – TRPh Apr 01 '21 at 19:09
  • 3
    This also works for Visual Studio 2022 – rasoul fetrati Aug 08 '22 at 22:04
  • 2
    Confirmed for VS 2022. – phuzi Sep 14 '22 at 21:54
  • 1
    This solution just helped me also in Visual Studio 2019! – Dmitriy Jan 13 '23 at 22:24
56

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

Balagurunathan Marimuthu
  • 2,927
  • 4
  • 31
  • 44
levelnis
  • 7,665
  • 6
  • 37
  • 61
  • Alternatively, 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. – Kyle Jun 11 '15 at 01:16
  • 4
    what if the error is in Visual studio for Mac? what would be the path for this folder? – Lost Nov 14 '17 at 19:28
  • 2
    I needed to close and open VS after and it works. Thanks – MusicAndCode May 06 '18 at 12:41
  • It's 2022 and the problem still persists with .Net (Core) - Deleting .Net Framework's temporary files is not going to work for non-.Net Framework projects/solutions. – phuzi Sep 15 '22 at 07:20
24

For me, this issue got fixed when I unloaded and reloaded the project again.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Skr
  • 391
  • 1
  • 3
  • 10
16

I had this issue and it was related to ReSharper.

Solution steps for me:

  1. Disable ReSharper

    VisualStudio\Tools\Options\ReSharper Ultimate\General\Suspend Now

  2. Build Solution

    (Ctrl + Shift + B)

  3. Re-enable ReSharper

    VisualStudio\Tools\Options\ReSharper Ultimate\General\Resume Now

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
samneric
  • 3,038
  • 2
  • 28
  • 31
  • Worked for me. Yes. ReSharper was the problem. – Muhammad Saqib Apr 20 '19 at 09:59
  • 2
    Suspend Now solves the issue. Resume Now - the issue is there again. – bahramzy Feb 04 '21 at 13:02
  • If 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 – NJS Mar 17 '22 at 17:20
  • Unloading and reloading did the trick for me. Don't have ReSharper. – Creative Sep 01 '22 at 11:25
  • Was having this issue and this answer didn't immediately solve my issue, using VS Professional 2022 w/ Resharper 2023... So I suspended, logged out of my Resharper acc, logged back in and updated to 2023.1, and the issue is all gone now. Thanks so much mate! – IfElseTryCatch Apr 12 '23 at 09:08
12

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.

Kevin Brydon
  • 12,524
  • 8
  • 46
  • 76
9

Do you have any plugins installed, like ReSharper? I had an issues with a bad plugin.

Try running Visual Studio in safe mode, to prevent plugins from running.

devenv /Safemode
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Marko
  • 2,734
  • 24
  • 24
  • 11
    I was using Resharper. You can disable ReSharper by using the Suspend button in menu Tools -> Options -> ReSharper. Then Resume it, it helped me. – Oleg Kyrylchuk Dec 22 '14 at 11:04
  • For me I don't know how Microsoft.ReportViewer.WinForms was in the Bin folder in my Web application! problem solved after deleting it. – A Ghazal May 26 '23 at 11:04
9

I had this problem after resolving some conflicts from Subversion (SVN). The solution has several projects in it and I resolved some conflicts in a few different projects. I did a menu BuildClean Solution followed by a men BuildRebuild Solution and everything was good again.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
LUKE
  • 1,375
  • 11
  • 9
7

If you are using ReSharper like me, you may delete ReSharper cache following by this link: Configure Caches

To specify the location for caches:

  1. Open the Environment → General page of ReSharper options.
  2. Use the Save solution caches in to select the location for cache files:
  3. User local settings folder to store them in the following directory: %LOCALAPPDATA%\JetBrains\Transient 4.System TEMP folder to store them in the following directory: %TEMP%\ReSharperCache
  4. Solution folder to store them in the root folder of the current solution
  5. Custom folder to choose a custom location for ReSharper cache files.
  6. Click Save to apply the modifications and let ReSharper choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see managing and sharing ReSharper settings.
  7. Reopen your solution for the changes to take effect.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
uzay95
  • 16,052
  • 31
  • 116
  • 182
  • 2
    The 'Clear cache' button on the Environment | General page of ReSharper options solved my problem. Thanks for the hint though! – nilsK Jan 10 '19 at 17:53
4

What works for me is deleting the IntelliSense indexfile.

The IntelliSense-file is in the same directory as you solution.

It's filename is SolutionName.sdf

Just delete this file, open you solution again, and IntelliSense will start rebuilding its indexfile. After that the problem will be gone.

A.Franzen
  • 725
  • 4
  • 10
4

In Visual Studio 2013 I solved this problem by deleting all of my obj and bin folders across all projects. The issue was probably due to solution configurations that I had deleted, but I hadn't been cleaned up properly, as doing a menu BuildClean Solution doesn't remove the old outputs from the obj and bin folders.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rocklan
  • 7,888
  • 3
  • 34
  • 49
4

This worked for me in Visual Studio Enterprise 2017:

  1. Navigate to Tools > Options > Text Editor > JavaSCript/TypeScript > Linting > General

  2. deselect "Enable ESLint"

Gerald LeRoy
  • 1,227
  • 2
  • 11
  • 17
  • 1
    After 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. – Nandolcs Mar 13 '19 at 19:59
4

I've run into this as well and was able to return Visual Studio to its normal state by doing the following -

  1. Identify the project where the red lined code comes from
  2. Remove the "red line" project from the references where it is being used (ProjectName\References - right click, add references, and uncheck the "red line" project)
  3. Build (you should get errors now)
  4. Readd the project reference that was just removed
  5. Build again
  6. The red lines should be removed and the project should build!
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Brian Mikinski
  • 123
  • 1
  • 10
3

Steps that work

  1. Open the solution and do a rebuild all
  2. Close the solution
  3. Open solution and do a clean
  4. Close solution
  5. Open solution and do a rebuild all
  6. Close and then open the solution. It should be good. This works for me every time

Be careful deleting some of these settings files as you will lose saved debug settings, etc. And it may do more damage than you realize.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Can 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. – Peter Mortensen Jun 11 '21 at 22:21
3

I have found recently it is easy to solve this by switching from Debug to Release in the dropdown to left of the Play Button. Then switching back from Release to Debug.

2

I had a similar problem when I was seeing lot of red squiggles in a couple of files. I tried all answers proposed previously, but nothing seemed to work.

The moment I started browsing through the classes, structures in other files for which complaining files had references, the problem disappeared. It seemed IntelliSense was not able to resolve dependencies on its own for some reason.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
irsis
  • 952
  • 1
  • 13
  • 33
  • 3
    I 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? – Sнаđошƒаӽ Nov 08 '16 at 15:16
  • 4
    @Sнаđошƒаӽ I think that is exactly what he is saying. – Robert Columbia Nov 08 '16 at 17:09
  • @RobertColumbia No offence to OP, but I think that's just ridiculous. – Sнаđошƒаӽ Nov 08 '16 at 17:25
  • @Sнаđошƒаӽ well that is what he is saying. If you think that strategy is not helpful, downvote the answer. – Robert Columbia Nov 08 '16 at 17:27
  • @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. – irsis Nov 09 '16 at 01:21
  • I 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. – nico Aug 22 '17 at 21:41
2

Simply refresh the project/solution. It will get resolved.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
S J Karthi
  • 51
  • 1
  • 6
  • 2
    How 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 Jun 11 '21 at 22:06
2

I had the same problem with lots of red lines in several *cpp source files. Though the code compiled perfectly. None of the other solutions worked for me.

Changing the order of #include lines of a *.cpp-file could make the red lines disappear - and reappear with the restored order.

Then I noticed a header file was included twice in a single *.cpp file. I removed the second one and - everything was fine.

Including a header file twice in the same *.cpp file seems to be no problem to the compiler but to the IntelliSense part.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
hartwin
  • 21
  • 1
2

Using VS2022 without Resharper when this problem occurred, tried several things, this did help me in the end:

  • Close Visual Studio
  • Delete folder .vs in the Solution folder
  • Go to folder %USERPROFILE%\AppData\Roaming\Microsoft\VisualStudio\
  • Delete all folders whose names start with 17.
  • Reopen Visual Studio

More specific subfolders could exist that might be enough to delete, but I had no issues after deleting all of it. AFAIK these only contains user session data, temporary files and/or cache files that can be downloaded again or recreated as needed.

Peter B
  • 22,460
  • 5
  • 32
  • 69
1

For me, I had at one time enabled fusion logging to debug some assembly dependency errors (fuslogvw from a CMD prompt). That was months ago and I had been experiencing much slower build times (5-7 minutes) since then.

I had also forgotten entirely that I had left them enabled. These logs were my bottleneck and disabling them has made iterating much faster.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tabrock
  • 1,120
  • 1
  • 20
  • 37
1

I ran into this problem with the latest Visual Studio 2017.
Also the debug version of my program was running painfully slow.

I deleted the Solution file .sln and created a new one.

juergen d
  • 201,996
  • 37
  • 293
  • 362
1

In my case with Visual Studio 2017, I have many "red lines" shown below all symbols defined in a third-party library, but my project can actually build without problems. I have tried all suggested solutions (like delete the .VS folder, restart Visual Studio, etc.), but none of them working.

Finally, I fixed it and this is how: I open my application project's property page, then go to C/C++GeneralAdditional Include Directories, which is the place I put all needed third-party library header paths.

I delete all the path (but save them somewhere), click "Ok" to confirm. Then I come back to the same setting, paste those paths back, click "Ok" to confirm, and then all those "red lines" disappear.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Hongkun Wang
  • 717
  • 8
  • 22
1

Found this solution:

  1. Close Visual Studio (ensure devenv.exe is not present in the Task Manager).
  2. Delete the %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\xx\ComponentModelCache directory.
  3. Restart Visual Studio.
ButchMonkey
  • 1,873
  • 18
  • 30
darrellh
  • 11
  • 1
1

I have VS2019 with ReSharper, and ran into this issue.

What worked for me was:

  • Go to the ReSharper >> Options menu
  • Go to the General tab (should be the default)
  • Press the "Clear caches" button
  • Close all instances of Visual Studio (2019)
  • Restart Visual Studio
Svein Terje Gaup
  • 1,424
  • 15
  • 29
0

I have had this problem for months and have finally fixed it. Closing Visual Studio and removing the .vs folder located in the solution directory did not work for me.

There was an assemblyIdentity tag in the web.config file which was referencing a library that was not in my references folder. I removed this tag, cleaned, closed and reopened, and the problem was fixed.

  1. Check each of the assemblyIdentity tags in your web.config file and check them against the references folder in solution explorer
  2. Remove any assemblyIdentity tags, including the parent dependentAssembly tag for any which aren't listed in your references folder.
  3. Clean the solution
  4. Close and reopen the solution
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Benjo
  • 179
  • 1
  • 8
0

Deleting .vs folder did the trick for me.

  • Consider reading others' answers in an old post. You can just upvote [this answer](https://stackoverflow.com/a/46599632/6670491), this is the Stack Overflow way of saying thank you. Instead of posting a duplicate. – HardcoreGamer Aug 27 '21 at 07:02
0

for me this works:-

  1. Open the Command Palette ctrl++p
  2. Then type: reload Window.
Jonathan
  • 1,955
  • 5
  • 30
  • 50
Ajay jangid
  • 711
  • 9
  • 9
0

Deleting all the folders which start with "asp.xxx" worked for me. You can reach these folders by: (C:\Windows\Microsoft.Net\Framework\vx.xx\Temporary ASP.NET Files)

metkopetru
  • 27
  • 7
-1

Hover over the word that has the red underline squibble. A mini dialog box will appear. Click on 'Quick fix' and then click on 'Disable error squibble'.

szs
  • 59
  • 1
  • 3