338

I have a problem with Visual Studio on a C# solution. It displays totally random errors, but the projects build. Right now, I have 33 files with errors, and I can see red squiggly lines in all of them.

I tried cleaning / rebuilding the solution, closing Visual Studio and even restarting my computer. I can modify .cs files and I see the changes in the solution.

Does anyone have an idea about why it does that?

Cydrick Trudel
  • 9,957
  • 8
  • 41
  • 63
  • 4
    Do you have ReSharper or any other addon like this installed? They can cause red squiggly lines too. – user1908061 Jul 17 '13 at 14:49
  • 4
    Try deleting the bin and obj folders from each project. – Charlie Brown Jul 17 '13 at 14:52
  • Errors or warnings? If project builds then it means that these are warnings. Disable all the addons and see how it goes. – Ehsan Jul 17 '13 at 14:52
  • We have the same issue with 2 of our machines on VS 2013 RC candidate. No Resharper installed though. The delemma here is that even though it builds without issues, no intellisense will work because it cannot 'resolve' namespaces and objects. Really weird. Works on 5 other machines perfectly. – Ryk Sep 13 '13 at 01:13
  • Unresolved conflicts in Team Foundation Server can also be a source of this problem. Getting the latest version may report that it is successful and all files updated, but that's not always true. If you go to Team Explorer > Pending Changes > Actions drop-down > Resolve Conflicts and click "Get All Conflicts" it should show you if there are any unresolved conflicts that you need to fix. – user2310967 Jan 21 '14 at 18:01
  • +1 for Charlie Brown's answer. VS2010 was picking up the errors but not preventing builds or anything like that; clearing the bin and obj folders sorted everything out. – Kyle Baran Feb 17 '14 at 21:16
  • In my case the culprit wasn't resharper, just the .suo file. – TTT Jan 08 '16 at 16:21
  • Here is my standard handling for weird VS behavior that works 99% of the time: https://stackoverflow.com/a/22838376/441729 – grahamesd Oct 09 '19 at 16:48
  • Clearing the VS cache worked for me. Here's the link [Visual Studio Cache Cleanup](https://www.matteopozzani.com/visual-studio-cache-cleanup/) – F0r3v3r-A-N00b Feb 13 '20 at 01:27

39 Answers39

345

If you have ReSharper, try emptying the ReSharper cache:

In menu, ReSharper > Options > Environment > General > Clear Caches

and disabling and re-enabling ReSharper:

In menu, Tools > Options > ReSharper > General > Suspend / Restore

Cydrick Trudel
  • 9,957
  • 8
  • 41
  • 63
  • 1
    this worked for me. I tried deleting the .vs folder and deleting all the bin and obj folders. It was clearing Resharper cache that finally fixed it for me in VS2022 – Emma Middlebrook Oct 21 '22 at 10:46
  • @Emma Middlebrook I tried this in Visual Studio 2022 but it did not work. Only removing .NET 7 from my computer fixed it for me. Resharper 2022.2.4 – Natrium Nov 15 '22 at 10:35
232

Clearing Resharper's cache did not help in my case, tried suspend/restore, and also Repair Resharper, using latest download off JetBrains' website - neither of these helped. This is after I tried close/reopen VS, restart my machine, repeat, Build/Rebuild and combination thereof.

It's interesting that suspending Resharper seemed to solve the problem after the 2nd restart of VS, but it was back after I enabled Resharper <-- I tried to do this sequence 2-3 times to ensure the pattern.

Anyway, I was still having issues when I found this article:

So I deleted the hidden .SUO file on the same folder level with solution, and it magically solved all reds.

Note - for Visual Studio 2015, the .SUO file is in .vs/[solution_name]/v14 hidden folder.

Community
  • 1
  • 1
Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151
  • 7
    The Resharper steps didn't work for me either, but this did. Thanks! – Justin Morgan - On strike Nov 03 '15 at 16:18
  • 4
    Your solution fixed it for me, after restarting visual studio. Thanks! :) – Moulde Dec 17 '15 at 13:32
  • 1
    VS2015 - I even had 1 project that wouldn't build but I could tell from the errors that it should have. I didn't have to close VS. Just closed the solution, delete .suo, and reopen the solution. Problem solved. – TTT Jan 08 '16 at 16:16
  • 1
    This worked for Visual Studio 2017, Resharper Ultimate and restoring of nuget packages that built ok but were being shown as errors. – Ralph Willgoss Aug 23 '18 at 08:42
  • For me it was a Resharper problem, I had to close and reopen the VS between disabling the Resharper and enabling it again: 1. Cleared the Resharper cache. 2. Disabled the Resharper. 3. Exit VS. 4. Entered VS 5. Enabled Resharper – Tal Segal Nov 05 '18 at 13:50
  • 13
    Still works with VS2019, thank you! The .suo file there is located at **.vs/[solution_name]/v16.** – Michael Armes Jul 17 '19 at 15:22
  • 6
    VS2019, I nuked the .vs directory, it was recreated on the next build--bogus error gone. – Loren Pechtel Sep 06 '19 at 21:46
158

tldr; Unload and reload the problem project.

When this happens to me I (used to) try closing VS and reopen it. That probably worked about half of the time. When it didn't work I would close the solution, delete the .suo file (or the entire .vs folder) and re-open the solution. So far this has always worked for me (more than 10 times in the last 6 months), but it is slightly tedious because some things get reset such as your build mode, startup project, etc.

Since it's usually just one project that's having the problem, I just tried unloading that project and reloading it, and this worked. My sample size is only 1 but it's much faster than the other two options so perhaps worth the attempt. (Update: some of my co-workers have now tried this too, and so far it's worked every time.) I suspect this works because it writes to the .suo file, and perhaps fixes the corrupted part of it that was causing the issue to begin with.

Note: this appears to work for VS 2022, 2019, 2017, and 2015.

TTT
  • 22,611
  • 8
  • 63
  • 69
  • 12
    "*I just tried unloading that project and reloading it, and this worked.*" I feel like I'm contributing to a cargo cult, but I ended up loading and unloading (with random cleans & builds in between), and eventually struck gold. So weird. This is with VS 2017. – ruffin Oct 12 '17 at 19:11
  • 2
    @ruffin - hehe. I think every answer to this question is a "cargo cult", but I believe mine is the quickest and least intrusive. ;) – TTT Oct 12 '17 at 22:05
  • 2
    Deleting the entire .vs folder did it for me in VS 2017 Community with ReSharper – Pedro Martins Timóteo da Costa Apr 02 '19 at 10:57
  • 3
    Unloading and reloading worked for me in VS 2019 CE too – Simon Apr 16 '19 at 09:49
  • 1
    Deleting .vs folder worked for me in VS 2019 with no ReSharper, just plain VS. THANKS!!! – German Latorre Jan 13 '20 at 14:52
  • 1
    Unloading and Reloading all of the projects worked for me in VS 2019 without ReSharper – Brendan Sluke Aug 18 '20 at 14:16
  • 1
    I've tried all of the above suggestions, and usually they work, but today this is the only thing that fixed it. Thanks! – esteuart Feb 22 '21 at 22:54
  • 1
    This seems to happen for us after csproj merges to projects that reference the merged project. Unloading and re-loading the referencing project(s) solves it every time for me. Thanks! – jonesy827 Sep 23 '21 at 20:55
  • 1
    Very good. That just worked for me, whereas restarting VS hadn't. I knew about the 'delete SUO and VS' workaround, but as you say, things get reset when you do that. – ChrisA Mar 08 '22 at 15:37
  • 1
    Still there in VS 2022! And the unload/reload project workaround works like a charm. I noticed that this occurs when switching from branch B to A and then back to B, and the problem projects are the ones present in B but missing in A. – kall2sollies Mar 30 '22 at 20:35
50

I cleaned solution, closed VS, reopened it, build solution, and red unresolved lines were cleaned and build succeeded.

pixel
  • 9,653
  • 16
  • 82
  • 149
  • 2
    These steps, followed exactly, worked for me. Simply cleaning and building would not work for me. – JasonCoder Jul 13 '16 at 14:08
  • 2
    Turn it off and back on again... you think I'd know to try that by now. +1 – iandisme Sep 30 '16 at 14:45
  • This solved the problem! But what caused it at the first place!? – DiligentKarma Oct 13 '16 at 18:20
  • 2
    I have no idea. I find Visual Studio to be most unstable IDE I have used. It keeps hanging, crashes often, and it shows strange errors every once in a while. I have stop counting the issues to be honest. – pixel Oct 14 '16 at 06:03
  • Following these exact steps did not solve the problem for me (in VS2015). – Tim Apr 29 '17 at 11:55
  • I have tried this many times, didnt help in this case. I even got compile errors so I couldnt start the application. I switched to Release, and then IntelliSense found a lot of the "missing" classes and I could build and start the project, but I still get errors in the list. – Ted Nov 18 '17 at 13:06
  • Obviously this is the first thing you should try. I wouldn't have googled the problem if fixing it was as simple as that. – BrainSlugs83 Sep 12 '18 at 20:18
  • Once again your answer saved my time after few months:P – Aneeq Azam Khan Nov 12 '21 at 06:05
50

I found that happens frequently when using Git in Visual Studio 2017, switching branches where there is dependent code changes. Even though the project will build successfully, there will remain errors in the error list.

These errors are often namespace issues and missing references, even when the library reference exists.

To resolve:

  • Close Visual Studio
  • Delete the {sln-root}.vs\SlnName\v15.suo file (hidden)
  • Restart Visual Studio
Rebecca
  • 13,914
  • 10
  • 95
  • 136
  • Thanks for this tip. It resolved an issue for us with VS 2017 (without any updates). FWIW, this happened to us after deleting and checkout a branch which had been rebased at the remote. – Mike Atkisson May 02 '18 at 15:04
  • 4
    While this solution didn't fix my problem, I do think this issue started after I was switching branches with uncommitted changes (because I needed to apply them to another branch) – CularBytes Sep 18 '18 at 12:15
  • This is exactly my issue. Thank you my savior – Dinh Tran Dec 07 '18 at 03:58
  • @CularBytes Might be worth stashing changes before switching branches. git stash, switch branch, git stash pop – Rebecca Dec 10 '18 at 11:23
  • this one actually worked – RonaldPaguay Jan 30 '23 at 02:44
27

I have tried all the 6 options, nothing worked for me. Below solution resolved my issue.

Close VS. Delete the hidden ".vs" folder next to your solution file. Restart VS and load the solution.

suresh t
  • 271
  • 3
  • 3
  • there seems to be a new cause for this problem, and this is the new solution to this problem. I know 3 other people that also with in days of you posting this also all of a sudden ran in to this problem. – Gerrie Pretorius Oct 09 '18 at 06:01
  • Had to do the same as Moshi. Doesn't appear to be a .suo file when running from VS 2019. One would have thought they would have fixed this issue by now...*grumble grumble grumble* – Mike Loux Jul 03 '19 at 15:42
  • For me fork too in vs2017 – Nejc Galof Jul 26 '19 at 13:34
  • 2
    @MikeLoux Take a look at the answer from Neolisk and you'll see he pointed out that the .suo file is now in the .vs folder, so all you need to do is delete that one file, not the whole folder. Not that this is particularly satisfactory either! – Avrohom Yisroel Jul 31 '19 at 13:42
  • Avrohom - that last bit sums it up perfectly. No, it's not very satisfactory at all. And, yes, I believe I ultimately did find the file where you and Neolisk pointed it out and have done that the few times it has reoccurred (not nearly as often, thankfully). So...that's something, I guess. :-) – Mike Loux Aug 05 '19 at 18:17
  • This one works 99% of the time for me whenever VS starts acting weird. – grahamesd Oct 09 '19 at 16:50
  • I have latest VS 2019 professional 16.8.6, still have false intellisense errors from time to time. This answer fixed my problem. Not sure it it will occur again – Charlie Feb 24 '21 at 23:15
21

Here's a collection of popular answers. Upvote the OP of the answer if it helped you:

Option 1: Clean, Build and Refresh (@Mike Fuchs option)

As @Mike Fuchs mentioned, try the following operations:

In menu, Build > Clean Solution

And

In menu, Build > Build Solution

and select the project in question, and click on the refresh button:

Refresh Button

Option 2: Clean, Close, Restart and Build (@Pixel option)

As @Pixel mentioned, try the following sequence of operations:

  1. Clean the solution
  2. Close Visual Studio
  3. Open Visual Studio
  4. Build solution

Option 3: Clear ReSharper cache (@GammaOmega option)

If you have ReSharper, try emptying the ReSharper cache:

In menu, ReSharper > Options > Environment > General > Clear Caches

and disabling and re-enabling ReSharper:

In menu, Tools > Options > ReSharper > General > Suspend / Restore

Option 4: Delete the .suo file (@Neolisk option)

As @Neolisk mentioned, deleting the .suo file might solve your problem. For Visual Studio 2015, the file is located in:

[Path of Solution]/.vs/[Solution Name]/v14/.suo

And for Visual Studio 2017:

[Path of Solution]/.vs/[Solution Name]/v15/.suo

Note that the .vs directory is hidden.

Option 5: Unload and Reload Project (@TTT option)

As @TTT mentioned, try unloading the project that causes problems:

In Solution Explorer, right-click on project, Unload Project.

And re-loading it

In Solution Explorer, right-click on project, Reload Project.

Option 6: Remove and add Microsoft.CSharp reference (@Guilherme option)

As @Guilherme mentioned, try removing and adding the reference to "Microsoft.CSharp" from the projects that have problems.

In Solution Explorer, expand the project, expand "References", right-click on "Microsoft.CSharp" and Remove.

Then, right-click on References > Add Reference, select "Microsoft.CSharp" from the list and click OK

Community
  • 1
  • 1
Cydrick Trudel
  • 9,957
  • 8
  • 41
  • 63
17

Delete the hidden file path = your solution\ .vs\ your solution Name \v15\ .suo

NoXSaeeD
  • 924
  • 1
  • 7
  • 13
  • 1
    worked for me too. VS 2019. WPF projects kept showing errors regarding controls not existing, but ran just fine. – Flemming Bonde Kentved Jan 06 '20 at 10:24
  • Ah, fixed. The green squiggly complaining was VS not ReSharper. I had a green underline in header file complaining that no definition for e.g. `CheckForErrors` could be found, even after completely renaming both the header decl and cpp impl (warning was still looking for `CheckForErrors` even though it was completely non-existent in my solution). Props ReSharper, this was VS' fault. – bunkerdive Apr 22 '22 at 02:05
13

I had a problem like this where Intellisense didn't seem to recognise the existence of one project (lots of "can't find this type", "this namespace doesn't exist", etc. errors).

Removing and re-adding the project reference in all the referencing projects would fix the issue, but the underlying cause could be fixed by editing the .proj file of the problem project.

Near the top of the "missing" project' .csproj file is an element:

<ProjectGuid>{GUID}</ProjectGuid>

and in all of the referencing projects .csproj files were project references:

<ProjectReference Include="..\OffendingProject\OffendingProject.csproj">
  <Project>{ANOTHER-GUID}</Project>
  <Name>Offending Project</Name>
</ProjectReference>

The referencing GUID didn't match the project's GUID. Replacing {GUID} above with {ANOTHER-GUID} fixed the problem without having to go through every referencing project.

Philip C
  • 1,819
  • 28
  • 50
9

So many things that could cause it, as evidenced by the long list of answers here. Here's what fixed it for me, having tried pretty much everything else first.

Build your solution in DEBUG mode. Then build it in RELEASE mode (it shouldn't build when it has red wavy lines, but in my case it was just warnings that should have had green wavy lines but it was getting in a muddle and giving them red wavy lines, and it built anyway even in release mode). Then build in in DEBUG mode. Spitting on your hands and turning around three times optional.

Worked for me, when nothing else did.

Jinlye
  • 1,774
  • 18
  • 19
  • Wow! That worked for me too, with latest version of VS2017 v15.9.30 :D Quick & simple too :) Bless you @Jinlye – Zeek2 Jan 06 '21 at 15:51
6

for VS-2017, deleting .vs folder worked for me.

5

Following solution worked for me

1 - Close VS

2 - Delete .vs folder

3 - Open VS

4 - Build solution

Vijay Hugar
  • 51
  • 1
  • 2
5

I've noticed that sometimes when switching git branches, Visual Studio (2017) will not recognize types from some files that had been added in the second branch. Deleting the .vs folder solves it, but it also trashes all your workspace settings. This trick seems to work well for me:

  1. Solution Explorer -> Find the file with the unrecognized class in it.
  2. Click Show All Files at the top of the Solution Explorer.
  3. Right-click the file -> Exclude from project.
  4. Right-click the file again -> Include in project.

This causes Intellisense to parse the file that it missed when switching branches.

Erik
  • 5,355
  • 25
  • 39
4

Occasionally I have to do a custom clean by going through all of the projects and manually deleting the "bin" and "obj" folders. To see them in Visual Studio, you'll have to enable hidden files and folders for each project. After this is done, rebuild the solution.

Technobabble
  • 996
  • 9
  • 25
4

My symptoms in VS2019 were that I would build with some errors. Then I'd fix the errors, and the build would work, as shown in the Output window. But the Errors windows still showed the old errors. I could run it just fine. Closing VS2019 and reopneing fixed the issue, but only for a little while. This started happening on version 16.4.3

This solution seems to work for me:

Uncheck Tools->Option->Projects and Solutions->General->Allow parallel project initialization

I found this fix buried way down in the comments here: https://developercommunity.visualstudio.com/content/problem/483450/vs-2019-intellisense-reports-compile-errors-when-r.html

Daniel Williams
  • 8,912
  • 15
  • 68
  • 107
3

Perhaps you try to reset your intellisense cache. I've had a similar issue in visual studio 2012 when working in a large project with many partial class definitions. Reducing the partials solved the problem partially, clearing the intellisense cache also - for a while.

3

Deleting .vs folder solved my problem.

But it also reset my solution's current settings in VS. Like, my unloaded projects in the solution were re-loaded and all the pinned and opened documents were also closed when I restarted the VS.

ndrwnaguib
  • 5,623
  • 3
  • 28
  • 51
Usman Farooq
  • 938
  • 8
  • 10
2

0 - Right click on the Solution and clean solution

1 - Close VS

2 - Delete project's .suo file

3 - Open VS

4 - Build solution

nPcomp
  • 8,637
  • 2
  • 54
  • 49
2

A colleague of mine experienced this issue today. We tried many of the recommendations here and none worked except the solution described below.

Problem:

Project builds fine but Intellisense fails to recognize certain types and marks particular using statements as invalid.

Solution:

Change the 'Solutions Platform' (in VS 2017 this is the dropdown next to the Solution Configuration dropdown and has values such as x86, x64, AnyCPU, Mixed Platforms, etc.) to AnyCPU.

The platform for your project may vary, but it seems as though some references may not be valid for all platforms.

AperioOculus
  • 6,641
  • 4
  • 26
  • 37
2

I've been struggling with this issue for over a year and none of these solutions helped me:

  • Delete .suo
  • Delete .vs folder
  • Delete any or all cache / temp folders
  • Delete obj / bin folders
  • Unload / reload project

I finally fixed this issue - I opened the vbproj/csproj file in notepad and noticed that in the ItemGroup section, there was a reference back to my main project dll. I deleted this reference, reopened my solution and the problem was fixed.

Benjo
  • 179
  • 1
  • 8
2

In my case helped a combination of things:

  1. deleting all old not needed files which were previously excluded from the project
  2. closing VS
  3. deleting all the bin folder contents
  4. deleting .vs folder
  5. Clean/Rebuild
  6. after that I still had some spurious errors, however the amount was significantly lower (from 200 to around 8) and the errors referred only to a resource dictionary path in Generic.xaml e.g. <ResourceDicitonary Source="example/path/somefile.xaml"> when I played around with the path trying to change it to a wrong one re-building then correcting it and rebuilding again, then this finally cleared all errors. It was specifically WPF project if that's relevant.
Piotr Golacki
  • 195
  • 3
  • 11
1

For my specific case it was a service reference another developer merged into the main branch. Which was perfectly fine except syntax highlight failed to resolve the generated service class and source was all red underlined. Cleaning, rebuilding, restarting did nothing.

All I had to do was refresh the service reference and VS managed to put the pieces together behind the scenes. No changes in the source code or generated files.

1

I've just ran into this issue after reverting a git commit that added files back into my project.

Cleaning and rebuilding the project didn't work, even if I closed VS inbetween each step.

What eventually worked, was renaming the file to something else and changing it back again. :facepalm:

KidCode
  • 3,990
  • 3
  • 20
  • 37
1

After trying all of the options listed I discovered yet another reason why this can happen. If somebody sent you the source code as a zip, or you downloaded a zip, Windows may have blocked all files. 2 ways to solve this:

Method 1:

Right click on the original Zip file -> Check 'Unblock' -> Click apply

Method 2:

If that's not an option, rather than opening properties on every file in the solution folder simply open power shell and unblock recursively using the following:

Get-ChildItem -Path 'C:\<ROOT FOLDER OF SOLUTION>\' -Recurse | Unblock-File
Conor Gallagher
  • 1,500
  • 2
  • 19
  • 42
1
  1. first close the solution.
  2. then solution cache file delete( in location C:\Users\Documents\Visual Studio\Backup Files/project cache file)
  3. then .suo file delete
  4. then solution open and build.

I hope solve your problem

Mahfuz Morshed
  • 108
  • 2
  • 9
1

Had this issue at work (running VS2017). Tried all of the answers here. No joy.

The project would build just fine, but was complaining that namespaces / types couldn't be found. Red squiggles all over the place. Lots of errors in the Error List window.

My solution contained 3 projects.

Discovered that 3 of the NuGet library references for one of the projects was out of line. Consolidated the referenced library versions, and Bingo.

Hope this helps someone.

Brett.

Brett
  • 1,540
  • 9
  • 13
1

Unload & reload the project fixed this problem.

Ankush Jain
  • 5,654
  • 4
  • 32
  • 57
0

Sometimes if you just clean solution the errors are disappearing, but they may eventualy come back afer a while or at the next build.

meJustAndrew
  • 6,011
  • 8
  • 50
  • 76
0

Ran into this issue with a single type not being recognized by Visual Studio which showed the red squiggle even though the solution built successfully. I noticed in the Solution Explorer the file did not have the expand arrow on the left which shows classes and properties on expansion.

The fix was to Exclude the file from the project and save/build which produced an expected error and then Include the file in the project and save and build.

After performing these steps Visual Studio started to recognize my type again. Looking at the diff in git it appears the issue was due to line endings not matching on the <Compile Include="..." /> line of my .csproj file.

Thorb
  • 81
  • 6
0

in my case vs was never retaining the imported namespaces in the project properties > references

when I tried to add/check them again I couldn't and vs threw an error and when saved project vs crashed. When I reopened all the standard imported namespaces (system.data etc...) were all ticked again and it then was recognising everything without error

m butler
  • 1
  • 1
0

TL;DR: Perform a clean re-install of Visual Studio

After wasting several hours, I still couldn't fix it for Visual Studio 2017. I then installed Visual Studio 2019 PREVIEW and all of a sudden, IntelliSense displays me the members of STL-classes again (which it doesn't with Visual Studio 2017).

So, my guess is that there might be also something wrong with Visual Studio itself (maybe something in the cache directory or in general something on your PC which is not directly related to a specific solution) which can be solved by a clean and complete re-installation of Visual Studio. I know, this is a stupid "solution", but in my case, only a fresh Visual Studio (2019) installation had an effect.

As already mentioned, in my case, only STL classes were affected. IntelliSense wouldn't display their members which is odd. I thought, it could maybe have something to do with precompiled headers. Somewhere I read that the STL and the project should be on the same drive and putting them onto the same should solve the problem. But none of these routes led to success.

j00hi
  • 5,420
  • 3
  • 45
  • 82
0

I found that this can happen if the referenced project is targeting a higher version of the framework than the project that is trying to use it. You can tell if this is the problem by going to the output window and looking for something similar to this:

The primary reference "my_reference" could not be resolved because it was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7".

The solution is to change the target framework of one or other of the projects.

michaela112358
  • 444
  • 4
  • 9
0

There are a lot of answers to delete the SUO / hidden solution files.

In my case it was because I needed to run Visual Studio as an Admin in order publish. Which overrode those files with admin permissions. Now when running as a standard user I can not get rid of any errors.

If I re-run in admin mode I am able to resolve all the errors.

0

In my case when I tried to work with a project written with C# 9.0 for the first time after updating sdk to latest, it would show red lines no matter what I did (it would build fine). I have tried everything here, but nothing worked. Finally I realised that the problem was with my Resharper's syntax highlighter from an older version. Once I updated Resharper all the red went away.

Tanuki
  • 717
  • 1
  • 9
  • 24
0

I experienced IntelliSense displaying distracting errors that did not exist, but still had the ability to build and debug the project in Visual Studio 2019. This issue did not occur in Visual Studio 2017. On top of this issue we were unable to navigate to various references in Visual Studio.

After trying all of the options posted and finding this post about navigating symbols: https://stackoverflow.com/a/49100341/999011

The solution for our situation was related to the Microsoft.Net.Compilers & Microsoft.CodeDom.Providers.DotNetCompilerPlatform references in the project file, which were mentioned in the above post.

However, I never updated them I just found that there were multiple references to different versions in the project file. After cleaning those up and only having one reference for each package Microsoft.Net.Compilers & Microsoft.CodeDom.Providers.DotNetCompilerPlatform, distracting red squiggles disappeared and navigating symbols started working.

I can only theorise that the extra references were added during upgrades as I think this project was originally created in Visual Studio 2015.

Matt Fricker
  • 479
  • 1
  • 6
  • 18
0

The best way to solve strange project configuration errors like this is to open the project file (right click on project select 'edit project file') then look at the item groups and see if the order and files in these list are what you expect them to be.

eg.

 <ItemGroup>
<Compile Remove="out\of\date\path\to\foo\foo.cs" />

etc.

Sometimes (especially if you move files around) the project file can get out of date and still have old invalid entries in it, and you'll never know it by looking in the solution pane settings.

ejectamenta
  • 1,047
  • 17
  • 20
-2

I solved this problem by deleting the temporary files of Microsoft .NET framework. Location: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files and C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

-2
REM DELETE ALL VS HIDDEN SOLUTION OPTION FILES
DEL /A:H /S *.SUO
Pang
  • 9,564
  • 146
  • 81
  • 122
-3

Try hovering with the mouse over the underlined elements. It should normally tell you what the problem. To see a list of all the errors/warnings, go to View => Error List. A table should open on the bottom of the IDE with all the errors/warnings listed.

ionutioio
  • 218
  • 1
  • 6
  • There are squiggly lines under random classes, but I do not get any errors in the error list. Furthermore, the projects builds perfectly. It looks like it is Intellisense-related. – Cydrick Trudel Jul 17 '13 at 15:19