73

I've noticed that the auto complete feature in Visual Studio no longer works properly once my project has reached a certain size (in my case ~4,100 lines of code). I've also noticed that performance also degrades once the number of third-party libraries increases (namespaces and class attributes and methods are no longer visible).

Is there a way of manually updating the auto completion database or create a new one for an existing project?

I am currently working under Visual Studio 2008, but I have experienced this issue in Visual Studio 2010 as well.

Sebi
  • 4,262
  • 13
  • 60
  • 116
  • Possible duplicate: [VS2010 IDE some Intellisense is not working](http://stackoverflow.com/questions/4830397/vs2010-ide-some-intellisense-is-not-working). – IInspectable Aug 17 '13 at 14:55
  • 3
    Intellisense has been broken forever. Remove the NCB file and it will work for a little while. – brian beuning Aug 17 '13 at 15:47
  • 3
    Or in the case of VS2010 and later, the .sdf file. MS uses a SQL Desktop database for their intellisense database starting with VS2010. Close your solution, delete the .sdf file, then reopen the solution. Let it cook for awhile, and it should scan your project (and *all* headers including system headers). – WhozCraig Aug 17 '13 at 17:29
  • @WhozCraig is correct. –  Aug 17 '13 at 17:43
  • Sebi, could you please accept Pavel's answer? It is likely the best solution in modern versions of Visual Studio. – Liam Bohl Jul 10 '23 at 10:41
  • 1
    @LiamBohl ; done – Sebi Jul 10 '23 at 12:24

9 Answers9

77

For VS2015, 2017 and VS2019 close Visual Studio and delete the .vs folder in the same folder as the solution. It contains among other things the intellisense database (it should be possible to delete only the files specific to intellisense, if we knew which ones). Note that if you delete the whole folder you will lose your window layout configurations etc.

For previous versions, close Visual Studio and navigate to your project folder. The *.sdf file there contains the intellisense database- if you delete this files and reopen your project in visual studio, it rebuilds the cache.

Deleting the sdf file solved the problem for me.

Sometimes working with a big solution (mainly C++ projects) becomes unbearably slow. To fix it you need to close the solution and go delete the .SDF file. After that it returns to normal again, for about a week, or so until you need to do it again.

The underlying cause is that the SDF file gets fragmented and, according to xperf profiling I've done, VS will sometimes do 20,000+ random reads from it when changing between debug and release. Putting the SDF files on an SSD fixes the problem but should not be necessary. VS needs to use the SDF file more efficiently and not do blocking SDF operations, ever.

Source: https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2255455-fix-the-delete-sdf-file-problem

Constantin
  • 8,721
  • 13
  • 75
  • 126
  • 30
    Under VS2015 and 2017 it now creates a .vs folder in the same folder as the solution. That is the folder that contains among other things the intellisense. Deleting it fixes the issue. – korbes May 18 '17 at 21:24
  • 8
    I second the `.vs` folder deletion. This is sometimes also solution to IntelliSense PCH problems, but beware - you will lose your window layout configurations etc. – user35443 Jun 18 '17 at 16:34
  • 1
    This also works with Visual Studio 2019 - I had a project that got a header file added to one source file, and even though it built correctly, the intellisense for that source file showed numerous red marks on the right. Nothing I tried would fix it, until I closed the solution, deleted the .vs folder, reopened the solution and rebuilt. – dgnuff Jun 10 '19 at 22:02
  • @korbes, I know this is an old post but I am troubleshooting an issue where the recommended solution is delete the vs folder or clear the cache. Problem, I don't see the folder and the option to clear cache does not show up in the edit--> IntelliSense menu. What can be done? –  Nov 04 '19 at 19:37
  • 1
    @ggcg The ".vs" folder is hidden by default - do you have "show hidden items" enabled in Windows? Which version of Visual Studio are you using? – Constantin Nov 05 '19 at 01:27
  • @Constantin, thanks. I eventually got it. But deleting it didn't fix my problem. –  Nov 05 '19 at 03:47
  • 7
    Not deleting the .suo file in there keeps the layout. I.e. we might not exactly know which files in the .vs directory are for Intellisense (though likely it's the .db files), but we do know .suo is for per-user solution-specific options. – stijn Mar 11 '20 at 12:46
  • Deleting .vs worked for me! Thanks – Rick May 10 '22 at 21:06
33

In Visual Studio 2022, open Tools -> Options -> [type in "database" in the search box] -> Text Editor -> C/C++ -> Advanced -> Recreate Database = TRUE, and then reopen the solution. enter image description here

Pavel Krassikov
  • 356
  • 3
  • 3
11

In VS2017 I often run into this situation when I use interop to call CPP from C#, when something is changing on the CPP side.. e.g. constructor arguments.

Unload and reload the CPP project in the solution helps to solve the red lines..

Goodies
  • 1,951
  • 21
  • 26
  • could you explain exactly what you've done? I'm suffering from the exact same situation. I am currently using CMake to build the projects so I don't know what reloading the CPP project exactly means. – KimHajun Jan 01 '20 at 11:18
  • Right click in project in Solution Explorer, choose Unload from menu. Then right click again, Reload. Red lines disappeared. But this is 1 year ago, maybe these intellisense marking issues were solved in VS2019 ? I did encounter a few occasions (e,g, a typo in a .csproj could cause it) and to solve that, see Constantins answer above. Deleting the .vs seems to be a "magic bullet" to solve problems with the VS state cache. – Goodies Jan 24 '20 at 03:17
  • This works for other project types and VS versions as well, just did this on a .NET Standard class library in VS2019. – StevoInco Dec 13 '20 at 05:44
10

I am using Visual Studio 2019 and have also been experiencing problems with Intellisense along with other features. I would be able to get through about 2 or 3 updates to a file before Intellisense stopped working along with code formatting.

The only way I was able to get things working again was to restart Visual Studio, I tried removing both the intellisense folder and the whole .vs folder but this didn't solve the problem, it helped but something else was going on.

I was finally able to fix this by turning off the Track changes option under

Tools->Options->Text Editor->General.

enter image description here

Andy Braham
  • 9,594
  • 4
  • 48
  • 56
  • 3
    **Track changes:** When the code editor is selected, a vertical yellow line appears in the selection margin to mark code that has changed since the file was most recently saved. When you save the changes, the vertical lines become green. – Simon_Weaver May 04 '21 at 06:52
10

Right click on the solution and press "Rescan Solution". It seemed to work for me. Screenshot of the menu with action highlighted

Alexander
  • 539
  • 5
  • 16
Digby Jones
  • 101
  • 1
  • 2
7

For Visual Studio 2017 (and I think Visual Studio 2019 also), close Visual Studio, go into the .vs folder in your projects folder and delete all the contents apart from the .suo file, then reopen Visual Studio.

This way you can rebuild the Intellisense cache without losing your preferences.

Aidan
  • 5,346
  • 2
  • 19
  • 18
5

After verifying daniol's results of Mar 15, I went into the .vs folder -> {MyProject} folder -> DesignTimeBuild folder and deleted the .dbtcache file and Intellisense now works "intelligently" with no loss of Window Layout or other .suo info. I suspect that the 'Diagnostics.DTBBLog' command offered by eq_ on Jan 4 did the same thing but that command seems no longer available, at least by that name.

E. Einfalt
  • 51
  • 1
  • 2
1

Encountered a related problem ("[n] source files to parse" instead of showing the Callers Graph) with Visual Studio 2008; deleting mentioned in previous answers files didn't help; what helped was:

  • In Solution Explorer, right-clicked on my project;
  • Selected "Properties" -> "Configuration " -> "C/C++" -> "Browse Information";
  • Changed "Enable Browse Information" from "Include All Browse Information (/FR)" to "No Local Symbols (/Fr)".

Voila!

-1

For Visual Studio 2017 (and mainly using C# projects), the following has always worked for me:

  • Open a Command Window (View/Other Windows/Command Window) [Ctrl+W,A]
  • Enter the command "Diagnostics.DTBBLog" and press enter

No need to close solution and reload etc. It was devastating to find out that for Visual Studio 2019 this command is removed...

eq_
  • 109
  • 6