CodeLens not showing references

Viewed 80142

CodeLens stopped working for some reason in project solution that I'm dealing nowadays. It is not showing references instead "- references". However, when I open up Visual Studio with another project It works like charm.I can confirm that CodeLens is enabled. Do you have any idea to make it work?

20 Answers

A simple solution, which works!

I did try enabling CodeLens in Visual Studio (2015) -->

  1. Quick Launch (Ctrl+Q) Ctrl+Q
  2. Options (CodeLens) CodeLens Options

But, it was enabled :( Then, it did work with: (Closing the programs), Win+R --> %temp% EnterDelete all

nothing but a Win+R

For me, CodeLens was disabled, so make sure it is still enabled.

I know it is an easy answer, but it might help some developers.

Go to Tools -> Options -> Text Editor -> All Languages -> CodeLens then click the "Enable CodeLens" option if it is not checked and then save it.

It looks like VS disabled it for some reason, maybe after an update or slow startup.

Just had this problem with VS 2019.

I tried disabling / enabling codelens and it didn't work.

I deleted the .suo after that and it didn't work.

I tried disabling / enabling codelens again (after deleting the .suo) and now it works again.

UPDATE (about 2 weeks later):

It started happening again and this time I disabled IntelliCode in Extensions and all of a sudden Codelens started working again.

UPDATE AGAIN (25 Nov 2019):

I reported this to Microsoft and had a dialog with them. You do not have to turn off all of Intellicode at this time, only disable Intellicode Refactorings in Tools -> Options -> Intellicode. The actual fix is slated for VS 2019 16.4 I believe.

Try deleting .suo file inside of the hidden .vs folder in your project. This worked for me in VS 2017.

My Problem Always directly after enabling CodeLens, press OK, i see the extra space required for the CodeLens information and than it disappears and when i look at the options again it is diabled. Driving me nuts.

Approaches Deleting caches/configurations. Clean start without Extensions work. Normal start without ReSharper works. Reinstall ReSharper + deleting cahces -> False behavior

Solution Unter Extensions - ReSharper - Options - Environment - Performance Guide was "Disable CodeLens for all languages" set to "Fix Silently". Set to Ignore -> WORKS!

hope this helps someone

In Visual Studio Professional or Enterprise you can enable CodeLens by doing this:

Tools → Options → Text Editor → All Languages → CodeLens->Enable

This is not available in some Community Edition versions

I have Visual Studio 2017 Professional on Windows 10. I have observed this under several circumstances:

  1. MicroSoft decided I needed some critical update for Windows and it installed while I was working - causing some of the VS components to crash.
  2. Visual Studio update was received in background.
  3. Some component of Visual Studio crashed - not the VS just some attached feature (did not note exactly which one)
  4. No known cause.

In each of these cases I did in order (sometimes it worked after each of these)

  • Build / Rebuild solution
  • Build / Clean Solution
  • Close and Restart Visual Studio
  • Remove Symbols cache, restart VS
  • Close BOTH VS and SSMS and restart them
  • Close VS and Restart Windows
  • Close VS, force all pending Windows updates to load, restart Windows
  • In options, Uncheck Codelens/apply and re-check/apply (OK button)

I tried most of the solutions above without luck, as I also saw this problem. On top, certain newly added classes were showing up as white/black (regular text) in Visual Studio.

Changing to Release typically helped, but wasn't a long-term solution. However, this helped on both issues - verified on another machine. Maybe some of the steps can be left out.

  • Close all document tabs
  • Clean solution
  • Right click on solution, click "Enable Lightweight Solution Load"
  • Close solution
  • Reopen solution
  • Right click on solution, click "Disable Lightweight Solution Load"
  • Close solution
  • Reopen solution
  • Rebuild

Explicitly enable CodeLens in the workspace settings.json:

// show code lens on editor
"editor.codeLens": true,

Verify that the following properties show on the editor:

// inline count of reference for classes, interfaces, methods, properties, 
// and exported objects
"typescript.referencesCodeLens.enabled": true

I could fix my problem with C# CodeLens and Omnisharp.

My C# extension was 1.25.0. What I did to fix my problem: C# extension -> Unistall -> Install another version -> Version 1.24.4 After that in the settings I searched for "omnisharp: use global mono" and set it from "auto" to "alwayse". Then restart Omnisharp and wait for it to compile and show references.

Related