11
votes

The Code Lens feature of Visual Studio 2013 won't work anymore. It says "Loading references for this method" but it takes years and actually it doesn't load them for any method at all.

It used to be working just fine but I am not sure why it stopped working. I restarted Visual Studio 2013 many times, I even restarted my computer but no luck.

Code Lens is not working anymore

It is enabled in my Visual Studio 2013.

enter image description here

4
Everything is checked in Tools -> Options -> Text Editor -> All Languages -> CodeLens ? - Scott Solmer
Yes, please see my updated question. - Tarik
When was the last time you ran a clean build? Did anything specific change before it stopped working? - Andrew Clear
I am not sure what changed before it stopped working but I tried many clean builds but nothing really seems working. - Tarik

4 Answers

8
votes

I will answer my own question as I managed to solve it.

It seems each time you run your tests in Visual Studio, it stores the result of your tests in TestResults folder in the project folder and it was about 800MB in size in my computer.

I just deleted it and clean the project bin and obj folders as well (which I did for several times before and didn't really work). But removing TestResults folder did the magic.

My guess is that because of the humongous size of the TestResults folder, Visual Studio 2013 cannot load all the results etc. quickly and that's why it was taking years to show me Code Lens feature. So delete that folder time to time for better performance.

Here are some results about TestResults folder after I googled it:

  1. How to: Deploy Files for Tests: http://msdn.microsoft.com/en-us/library/ms182475.aspx
  2. How to preserve the test results directory?: http://blogs.msdn.com/b/aseemb/archive/2013/02/23/how-to-preserve-the-test-results-directory.aspx
  3. How to delete Test Results folder:http://blogs.msdn.com/b/ploeh/archive/2006/07/13/cleaningawaythetestresultsfolder.aspx

UPDATE

Even if those methods above may work for you, I realized that they actually fixed this issue since Visual Studio 2013 Update 2. So instead, please update and install it.

4
votes

In case the the above solution isn't working for anyone else, I had a different fix that worked for me. In my case it showed that I had references, but would not display the details or links about them.

I had to install a new extension to reset a MEF cache corruption. This fixed code lens and the Page '312e8a59-2712-48a1-863e-0ef4e67961fc' not found error.

http://www.hjerpbakk.com/blog/2014/7/25/no-content-in-solution-explorer-using-visual-studio-2013

1
votes

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.

0
votes

CodeIndexing must be enabled on the TFS Server. You can check this setting using TFSConfig:

 TFSConfig CodeIndex /indexingStatus /collectionName:"YourCollectionNameHere"

You can start indexing with:

 TFSConfig CodeIndex /setIndexing:on /collectionName:"YourCollectionNameHere"