70

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.

4
  • Possible duplicate: VS2010 IDE some Intellisense is not working. Aug 17, 2013 at 14:55
  • 3
    Intellisense has been broken forever. Remove the NCB file and it will work for a little while. Aug 17, 2013 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, 2013 at 17:29
  • @WhozCraig is correct.
    – user152949
    Aug 17, 2013 at 17:43

9 Answers 9

74

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

8
  • 28
    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, 2017 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, 2017 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, 2019 at 22:02
  • 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 5, 2019 at 1:27
  • 6
    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, 2020 at 12:46
27

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

1
  • 4
    This also worked in Visual Studio 2019.
    – pugdogfan
    Nov 8, 2022 at 13:48
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..

3
  • 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 1, 2020 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, 2020 at 3: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, 2020 at 5: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

1
  • 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. May 4, 2021 at 6:52
8

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

2
  • This option doesn't exist for me on Version 17.3.5 Dec 8, 2022 at 14:07
  • In VS2022 (Version 17.2.5), it is now on the Project items, not the top-level Solution
    – CSM
    Jan 19 at 10:52
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.

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.

2
  • 2
    Addendum: To verify this solution, I restored the .dtbcache from the RecycleBin and all the issues with Intellisense not tracking changes returned.
    – E. Einfalt
    Jul 13, 2021 at 23:54
  • Addendum: For follower info, I did this on VS 2019 v10.16.3.
    – E. Einfalt
    Jul 13, 2021 at 23:57
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!

New contributor
Vitaly Bortz is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
-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...

1
  • 2
    "Command "Diagnostics.DTBBLog" is not valid"
    – daniol
    Mar 15, 2021 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.