CodeLens not showing references

Visual StudioTfsCodelens

Visual Studio Problem Overview


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?

Visual Studio Solutions


Solution 1 - Visual Studio

My Solution:

Toggle the CodeLens feature off and then on again.

  • Go into Tools -> Options... -> Text Editor -> All Languages -> CodeLens.
  • Uncheck "Enable CodeLens" option and click OK.
  • Go back into Tools -> Options... -> Text Editor -> All Languages -> CodeLens.
  • Check the "Enable CodeLens" option and click OK.

Note: I've fixed the issue once before by closing the problem .cs file and then reopening it. Closing any referenced files may also be required.

My Problem(s):

Similar to the original poster, CodeLens stopped refreshing references after I made a bunch of refactors. I was seeing stale references to code that didn't exist and I was also seeing the "- references" issue as described in the original post.

My Environment & Specific Scenario:

  • Visual Studio 2015 with Service Pack 2 and Resharper Ultimate 10.0.1
  • I was doing a major overhaul with a ton of refactoring and my project wasn't compilable for an hour or so. Once I could compile the project again, the references weren't working.

Solution 2 - Visual Studio

Same problem here.
CodeLens works normally with small solutions, but not working with large ones.
And this behavior is accompanied with crash of Alm.Shared.Remoting.RemoteContainer.dll process.
Tried in VS 2013 Update 4 and VS 2013 Update 5 RC.
Solution:
Close all programs and clean %LocalAppData%\Temp folder (or maybe just ALM folder inside it).

Solution 3 - Visual Studio

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

Solution 4 - Visual Studio

Try to remove .suo file which is storing some enviroment/solution settings. This helped me.

Solution 5 - Visual Studio

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.

Solution 6 - Visual Studio

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.

Solution 7 - Visual Studio

You may have circular references in your solution that prevents CodeLens from working. Some details were provided in the comments for this issue on the Visual Studio Connect site:

>>> Somehow, two of my projects in my solution ended up referencing each >>> other causing a circular reference. I think it was a by-product of >>> Resharper's shortcut to reference an undefined class. Once I was >>> cleaned up all of the references, I'm now getting valid values in my >>> reference counts. >> >> How did you go about "cleaning" up references? > > In my case, my solution has multiple project files. In the references > folder of Project A, there was a reference to Project B. In the > references folder of Project B, there was a reference to Project A. > This was causing the circular reference. If you try to do this > "manually", VS will prompt you with a warning regarding the circular > reference. > > To clean this up, I removed the reference to Project B from my Project > A. I had do some minor class definitions in my Project B so everything > would still compile in the end.

Solution 8 - Visual Studio

I found out that if you block the Visual Studio with the Firewall, the Code Lens did not work.

So unblock it from the firewall to make it work.

Or edit Firewall settings for file:

C:\Windows\Microsoft.NET\assembly\GAC_32\ 
   Microsoft.Alm.Shared.Remoting.RemoteContainer\
   v4.0_12.0.0.0__b03f5f7f11d50a3a\
   Microsoft.Alm.Shared.Remoting.RemoteContainer.dll

Solution 9 - Visual Studio

I had this problem with VS2015 that already had "update 1" installed. The thing was that I originally installed VS2015 with the "custom" setup, not the "default" option, and I accidentally left out the "Git for Windows (3rd party)" option under "Common Tools".

This can be fixed by these steps:

  • Run the VS2015 setup again (from control panel - uninstall program)
  • Right click VS2015, select "Change"
  • On popup screen, select "Modify"
  • On setup screen, select "Git for Windows (3rd party)"
  • Move on with the setup, install selected features

Solution 10 - Visual Studio

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

Solution 11 - Visual Studio

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

Solution 12 - Visual Studio

I had the same problem, but one's of my colleagues who has the same development environment than me, doesn't have it...

The only one difference between our both environment was the quantity of RAM. There is 10GB allocated to his VM, and on mine, there is 6GB allocated. Since I upgraded the quantity of RAM allocated to my VM to 8GB, all my references are shown !

Solution 13 - Visual Studio

Installing Update 1 for Visual Studio 2015 fixed the problem for me.

Download Update 1

Solution 14 - Visual Studio

After reading the answer to this Stack Overflow question https://stackoverflow.com/questions/31570140/codelens-only-showing-references I decided my problem with Codelens was I was running Visual Studio 2015 Update 1 but was using Team Foundation Server 2012. I upgraded to TFS 2015, which upgraded in place and didn't require any new settings or URIs to be connected to Visual Studio as before. Then I reloaded my solution - but I still had the issue where it just said "– references" everywhere. I closed Visual Studio, started it again and reloaded my solution and finally I saw the correct reference counts as they used to show.

Solution 15 - Visual Studio

I found on the new VS 2015 update 3 it happens on a large class in a medium level solution 10+ projects and has nothing to do with circular references, a bad SUO file, or other things. It appears just deleting the temp file location(as mentioned already), closing VS and then reopening and hitting 'ALT+2'(forcing a reference find for Code Lens) made it magically work for me.

It also appears in some solutions and projects Visual Studio will create an old referenced suo file in .vs folder. I don't know the exact rhyme or reason, but it could be created in my case and the CodeLens worked again. It could potentially be a Visual Studio options is somehow referenced in projects under source control. As I know this happened with an older solution I have upgraded many times that was under GitHub control and it does have an .gitignore file(ignore files could change depending on source control). Suffice to say I have had similar things happen with other techs in the past when there is a lock on a source control file that should be updated and won't update. Simple answer is to add to an ignore and delete the settings file.

Solution 16 - Visual Studio

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)

Solution 17 - Visual Studio

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkkocabiyikView Question on Stackoverflow
Solution 1 - Visual StudioGrayDwarfView Answer on Stackoverflow
Solution 2 - Visual Studiofrobo7View Answer on Stackoverflow
Solution 3 - Visual StudioIrfView Answer on Stackoverflow
Solution 4 - Visual StudioIvan StelmakhView Answer on Stackoverflow
Solution 5 - Visual StudioBashir MomenView Answer on Stackoverflow
Solution 6 - Visual StudioMike CheelView Answer on Stackoverflow
Solution 7 - Visual StudioEric JohnsonView Answer on Stackoverflow
Solution 8 - Visual StudioAristosView Answer on Stackoverflow
Solution 9 - Visual StudiovpalmuView Answer on Stackoverflow
Solution 10 - Visual StudioEmulicView Answer on Stackoverflow
Solution 11 - Visual StudioMarco GView Answer on Stackoverflow
Solution 12 - Visual StudioKévin SIMON-QUESNELView Answer on Stackoverflow
Solution 13 - Visual StudiomartinossView Answer on Stackoverflow
Solution 14 - Visual StudioStackOverflowUserView Answer on Stackoverflow
Solution 15 - Visual StudiodjangojazzView Answer on Stackoverflow
Solution 16 - Visual StudioMark SchultheissView Answer on Stackoverflow
Solution 17 - Visual StudioJimmy B. CarlsenView Answer on Stackoverflow