Visual Studio 2022: Codelens Not Showing References

Steven Jul 09, 2026

Are you a developer using Visual Studio 2022 and facing issues with CodeLens not showing references? You're not alone. CodeLens is a powerful feature in Visual Studio that provides inline code metrics and quick actions, enhancing your productivity. However, when it's not displaying references as expected, it can be quite frustrating. Let's delve into this issue and explore potential solutions.

Visual studio extensions
Visual studio extensions

Before we dive into troubleshooting, let's ensure we're on the same page. CodeLens, introduced in Visual Studio 2012, displays inline code metrics and actions directly in the editor. It's designed to provide quick access to relevant information and tasks, improving your coding experience. Now, let's address the problem at hand.

the visual studio code is shown in this screenshote screen shot, with text below it
the visual studio code is shown in this screenshote screen shot, with text below it

Understanding the CodeLens Reference Feature

CodeLens reference feature displays the number of references to the symbol at the caret, along with a list of references when clicked. It helps you understand the impact of changing or deleting a particular piece of code. So, when this feature isn't working, you might be missing out on crucial information.

an image of a computer screen with some text on it and two other screens showing the same
an image of a computer screen with some text on it and two other screens showing the same

To ensure we're addressing the correct issue, let's confirm that CodeLens is enabled and configured properly.

Checking CodeLens Settings

VS Code: Getting Started, literally
VS Code: Getting Started, literally

First, ensure that CodeLens is enabled. Go to 'Tools' > 'Options' > 'Text Editor' > 'C/C++' > 'Advanced'. Scroll down to the 'CodeLens' section and make sure the 'Enable CodeLens' checkbox is checked.

Next, check if the reference feature is enabled. In the same window, under 'CodeLens', ensure that 'Show references' is also checked.

Restarting Visual Studio

an image of a computer screen with some text on it
an image of a computer screen with some text on it

Sometimes, simple solutions like restarting Visual Studio can resolve the issue. Close Visual Studio, reopen it, and check if CodeLens is now displaying references.

If the problem persists, let's explore some more advanced troubleshooting steps.

Resetting CodeLens Cache

the ultimate guide to how to run claude code for free on windows and mac
the ultimate guide to how to run claude code for free on windows and mac

Visual Studio caches CodeLens data to improve performance. However, this cache can sometimes cause issues. Resetting the cache might resolve the problem.

To reset the CodeLens cache, follow these steps:

Visual Studio Code setup—Part 1
Visual Studio Code setup—Part 1
the old studio paint layout is shown in black and white
the old studio paint layout is shown in black and white
6 Visual Studio Code Extensions I Cannot Live Without
6 Visual Studio Code Extensions I Cannot Live Without
Visual Studio IntelliSense Not Working? Multiple Ways for You! - MiniTool
Visual Studio IntelliSense Not Working? Multiple Ways for You! - MiniTool
User and workspace settings
User and workspace settings
Building a Visual Studio Code Extension
Building a Visual Studio Code Extension
Ready to Code Python in Visual Studio? Let’s Set It Up
Ready to Code Python in Visual Studio? Let’s Set It Up
Visual Studio Code Tutorial for Beginners - Introduction
Visual Studio Code Tutorial for Beginners - Introduction
Samouczek: tworzenie prostej aplikacji konsolowej w języku C# - Visual Studio (Windows)
Samouczek: tworzenie prostej aplikacji konsolowej w języku C# - Visual Studio (Windows)
Start Coding in Your Browser With Microsoft Visual Studio Online
Start Coding in Your Browser With Microsoft Visual Studio Online
20 Powerful VS Code Extensions for Front-End Developers
20 Powerful VS Code Extensions for Front-End Developers
Visual studio code – for writing XS – Age of Mythology Heaven
Visual studio code – for writing XS – Age of Mythology Heaven
How to Install Visual Studio Code on Windows PC & Laptop
How to Install Visual Studio Code on Windows PC & Laptop
How to Install Visual Studio Code on Windows Step by Step
How to Install Visual Studio Code on Windows Step by Step
the rest client page is displayed in this screenshot
the rest client page is displayed in this screenshot
Visual Studio vs Visual Studio Code: What’s Different?
Visual Studio vs Visual Studio Code: What’s Different?
how to create simple desktop apps in visual studio
how to create simple desktop apps in visual studio
How - You don't need to learn to code anymore.  Here's how to prompt Claude Code (zero coding):  Comment
How - You don't need to learn to code anymore. Here's how to prompt Claude Code (zero coding): Comment
10 VS Code extensions I can't live without
10 VS Code extensions I can't live without
How to Program Collaboratively Using Visual Studio Code's Live Share
How to Program Collaboratively Using Visual Studio Code's Live Share
  1. Close Visual Studio.
  2. Delete the contents of the following folder: %LocalAppData%\Microsoft\VisualStudio\17.0\ComponentModelCache. Be careful not to delete the folder itself, just the contents.
  3. Reopen Visual Studio and check if CodeLens is now displaying references.

Repairing or Reinstalling Visual Studio

If resetting the cache doesn't work, there might be an issue with your Visual Studio installation. You can try repairing or reinstalling Visual Studio to fix the problem.

To repair Visual Studio, go to 'Control Panel' > 'Programs' > 'Programs and Features', find Visual Studio in the list, right-click it, and select 'Change'. Then, choose 'Repair'.

If repairing doesn't work, you might need to uninstall and then reinstall Visual Studio.

Updating Visual Studio

Ensuring your Visual Studio is up-to-date can also help resolve issues. Microsoft regularly releases updates that include bug fixes and improvements. Check for updates by going to 'Help' > 'Check for Updates'.

If you're using a specific version of Visual Studio, make sure you're using the latest build of that version.

Checking for Extension Conflicts

Extensions can sometimes cause conflicts with Visual Studio features. To check if an extension is causing the issue, try disabling your extensions temporarily. Go to 'Extensions' > 'Manage Extensions', select each extension, and click 'Disable'.

If CodeLens starts working with all extensions disabled, enable them one by one to identify the problematic extension.

Remember, patience and persistence are key when troubleshooting technical issues. If none of the above solutions work, consider reaching out to the Visual Studio community or Microsoft support for further assistance.