Documenting has never been so easy

Helixoft Blog

Peter Macej - lead developer of VSdocman - talks about Visual Studio tips and automation

It surely happened to many of us. All of a sudden, IntelliSense is no longer working as expected. The most apparent sign of this is that you no longer see the compiler error underlines in your code at design time. For example, the duplicate declaration error below is not reported:

clear intellisense csharp error

However, if you build the project, you get the errors in the output window. Moreover, these errors are not necessarily listed in the Error List window. My experience is that if you display them for Build + IntelliSense (which is probably the default setting), the build errors are not listed.

clear intellisense error list1

However, if you switch to Build Only, the error is listed after the build has finished unsuccessfully.

clear intellisense error list2

The situation may also be quite opposite. There is no error in the code and the project build fine. But IntelliSense keeps displaying the compile errors.

Solutions

 If you need a quick fix, jump directly to the solution 4.

Solution 1

Restarting Visual Studio doesn't help. We need to delete the wrong IntelliSense cache. It's stored in the .vs folder in the solution root folder. The easiest way is to close the solution and manually delete the .vs folder. This will help. But it erases all your user-specific settings, such as open documents, bookmarks, breakpoints, configuration, etc.

Solution 2

A less invasive solution would be to delete only the .suo file inside the .vs folder. But still, this file contains many other settings that will be lost along with the IntelliSense cache data. And what's worse, it doesn't help in some cases. For example, I've encountered the following situation. I deleted the .suo file. After I opened the solution, IntelliSense was working fine. But this deletion has reset my other settings, including Configuration+platform. It reset my solution configuration to Debug|Mixed platforms. This is not what I wanted, and I changed it to Debug|AnyCPU. And guess what… The IntelliSense problem appeared again. But only in the Debug|AnyCPU. If I switched to Debug|Mixed platforms or Release|AnyCPU, everything was working fine. But there was no way to reset the wrong cache and keep the solution in Debug|AnyCPU.

Solution 3

The only solution is to delete only the IntelliSense data from the .suo file while keeping all other settings. The solution user options (.suo) file is a structured storage, or compound, file stored in a binary format. It contains multiple streams with unique names. Our goal is to delete just those streams that contain the wrong data and keep all the others.

There are several tools for viewing and writing the compound file binary files:

  • SSView with a nice GUI, but is not free for commercial use.
  • Free suo command line tool. But it only allows reading the files, not writing.

If you want to write your own tool or VS extension, there is a free C# library called openmcdf, also available  as NuGet. VSIX developers may use dedicated interfaces, but I'm not sure that they allow enumerating the existing streams in the file.

The simplest way is to do it manually. Close the solution and open the .suo file in SSView. It will list all the streams and because many of them have quite self-explanatory names, you get the picture of what is stored in this file. This is not the case for the IntelliSense data. The names are not that obvious, but they have suffixes: _ProjState and _TFMCaps.

clear intellisense suo streams list.png

They are in pairs, and it seems that each pair corresponds to a language used in the solution. For example, I found two language services in my solution above. One for C# and one for VB, as our solution contains projects written in both languages. Just right-click on each of them and select Delete. That's all. There's no Save button. Just close the tool and reopen the solution in VS. Everything should work now and no visible setting should be lost. I suspect that the deleted streams contained also other data in addition to the IntelliSense cache, but I didn't notice anything in VS GUI.

Solution 4

I've implemented the solution 3 in a new free Visual Studio extension named Clear Solution IntelliSense Cache. You can install it in your VS and fix the issue with a single click.

clear intellisense solution menu

 

Start generating your .NET documentation now!

DOWNLOAD

Free, fully functional trial

Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Quantcast
Accept
Decline