Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
Visual Studio

Visual Studio: Fix CodeLens Reference Counts Staying at Zero for an Entire Solution Because the Local CodeIndex Cache Under %LocalAppData% Never Finished Its Initial Build

- 11.11.26 - ErcanOPAK

🛠️ Visual Studio: Fix CodeLens Reference Counts Staying at Zero for an Entire Solution Because the Local CodeIndex Cache Under %LocalAppData% Never Finished Its Initial Build

CodeLens relies on a background indexing service that builds and caches the solution’s full symbol-reference graph the first time a solution opens, storing that cache under the hidden .vs folder and under %LocalAppData%. On a large solution opened right after upgrading Visual Studio or an extension, the initial build of that cache can get interrupted — closing Visual Studio, the machine sleeping, a crash — leaving behind a half-built cache that CodeLens then trusts indefinitely instead of ever retrying on its own.

🔎 The Problem

CodeLens references above a method, large solution right after upgrading VS:
  0 references | 0 callers          <- every method in the solution, always zero

Same solution, cache folder deleted and reopened (full reindex forced):
  14 references | 3 callers          <- real numbers return once indexing completes

✅ Fix: Force a Clean Reindex and Let It Finish

  • Close Visual Studio, delete the solution’s hidden .vs CodeLens cache subfolder (or the whole .vs folder) along with the global cache under %LocalAppData%\Microsoft\VisualStudio\<version>\ComponentModelCache, then reopen the solution so indexing starts completely fresh instead of resuming from a half-built cache.
  • Watch the status bar and the Output window’s CodeLens pane during the first reopen and let that initial indexing pass finish completely before touching any file — closing Visual Studio or sleeping the machine mid-index is exactly what leaves the cache in this half-built state the next time.
  • For a genuinely large solution, disable CodeLens indicators you don’t rely on (Tools > Options > CodeLens) so the remaining indexers have less to build and are less likely to be interrupted before finishing.

🚨 Why This Is Dangerous

Trusting a “0 references” result can make you delete a method, property or event you believe is unused, only to discover at runtime that it’s called from reflection, a different project, or code the broken index simply never finished scanning.

CodeLens’s numbers are only as fresh as its last completed index — a stale, half-built cache reports confident zeros instead of admitting it never finished counting.

— Developer Tip

Related posts:

Visual Studio: Master Code Navigation with Go To

Visual Studio: Master Code Navigation with Go To

Visual Studio: Fix a Test Explorer That Shows Tests as Not Run After a Successful Build

Visual Studio: Fix a Test Explorer That Shows Tests as Not Run After a Successful Build

Visual Studio: Fix a Breakpoint Never Hitting Because Just My Code Treats an Optimized Release DLL a...

Visual Studio: Fix a Breakpoint Never Hitting Because Just My Code Treats an Optimized Release DLL a...

Views: 5

Post navigation

Docker: Fix a Container Stuck in a Tight Restart Loop With Nothing Ever Printed in docker logs Because the Entrypoint Script Crashes Before Its Output Buffer Gets Flushed to Stdout
C#: Fix IEquatable Being Implemented on a Type but Dictionary Keys Still Coming Out Duplicated Because GetHashCode Was Never Overridden to Agree With It

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (980)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (857)
  • How to select distinct rows in a datatable in C# (853)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (653)
  • Add Constraint to SQL Table to ensure email contains @ (608)
  • Average of all values in a column that are not zero in SQL (570)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (546)
  • Find numbers with more than two decimal places in SQL (475)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

  • How to make theater mode the default for Youtube (1,055)
  • Get the User Name and Domain Name from an Email Address in SQL (980)
  • How to add default value for Entity Framework migrations for DateTime and Bool (977)
  • Get the First and Last Word from a String or Sentence in SQL (857)
  • How to select distinct rows in a datatable in C# (853)

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com