If you've stumbled upon this post it most likely means that you're struggling with a strange issue with Visual Studio Intellisense: it seems to work fine for existing files, but it show non-existing "errors" (in the Error Window and through the "red wavy underlines" inside the file) when you either create a new source code file or copy/paste an existing one.
These errors are usually related to "missing" classes or namespaces, that do actually exist (and often even compile properly).
Luckily enough, there are a couple workaround that can hopefully fix this nasty issue.
Fix #1: Delete the /.vs/ folder
The first thing to try when this issue hits your project is to entirely remove the /.vs/ folder, which is the directory where Visual Studio stores some user-related configuration files and temporary data: deleting that folder is safe, since VS will automatically recreate it when it opens the solution (if it doesn't exist).
Here are the required steps to do:
- Close Visual Studio
- Delete the /.vs/ folder (which can be found in the solution's root folder).
- Re-open Visual Studio
It's worth noting that the /.vs/ root folder only exists since Visual Studio 2015: if you're using Visual Studio 2013 or below, you can achieve the same results by directly deleting the .suo solution file, which is placed in the solution's root folder as well.
Fix #2: Delete the /bin/ and /obj/ folders
If the above method doesn't fix your issue, you can try to do the same with the /bin/ and the /obj/ folders:
- Close Visual Studio
- Delete the /bin/ and /obj/ folders (which can be found in the solution's root folder).
- Re-open Visual Studio
This workaround is often required when those folders contain some old DLL file (for example, when you change the Assembly Name of one or more projects): when this happens, the Build -> Clean command might be unable to automatically sort things out, since it will only clean up the known project files.
Sources
- https://stackoverflow.com/questions/51254108/visual-studio-2017-intellisense-is-not-working
- https://weblog.west-wind.com/posts/2018/Aug/07/Fixing-Visual-Studio-Intellisense-Errors