I had a set of very strange problems after upgrading to Visual Studio 2019 early this week, and they were significantly hampering my ability to get work done.  

  1. Go To Definition didn't work for a great many classes, methods, and properties.
  2. Intellisense was straight-up missing in multiple places.

I hadn't realized how much I relied on those two features of Visual Studio until I could no longer use them. It was like suddenly missing a finger, or being unable to find my phone: part of myself was gone.

"I can hear it buzzing. Where the $#^! is it?!" Photo by André François McKenzie / Unsplash

I went off to Google the problem and found nothing that helped me. So, when I eventually did find the solution that worked for me, it occurred to me that I cannot be the only one with this problem. Hence, this post.

Here's how I fixed my missing Intellisense and nonfunctional Go To Definition in Visual Studio 2019.

(If you're just looking for the solution, jump to the Summary section at the bottom)

Tracking the Problem

Our project is an ASP.NET Framework 4.5.2 MVC solution, with lots of other tech thrown in (e.g. Entity Framework). As I mentioned at the time, the Intellisense and definitions were not missing for all of my classes, methods, etc., just for a majority of them. For example, in my controllers I could not use Go To Definition on the ASP.NET MVC Controller class, nor the attribute HttpGet, nor any of our custom classes for this project. But I could use it on certain common extensions, such as ToString or ToList.

It took me a while to work this out, but I eventually determined that what I was actually missing was all of ASP.NET MVC and Entity Framework. With that commonality in mind, I started poking around the solution, which is when I discovered this:

All of my project references were in error! Even ones that should exist on my system, like System.Data.  

Which is stupid. I can use this project perfectly fine in VS 2017, so why was VS 2019 giving me such problems? And, more importantly, what was I going to do about it?

Potential Solution #1: Delete the .vs File

A bit of googling lead me to this blog post by Rick Strahl which suggested that I should delete the hidden .vs folder at the root of my solution. When I did so and opened Visual Studio again, VS recreated this folder. But, unfortunately, it didn't fix the issues I was having with Intellisense and Go To Definition.

It was at this point that something occurred to me: all of the things which I could not get Intellisense for (MVC and EF) were, in fact, NuGet packages. I wondered if this had something to do with NuGet, and, it turns out, it does!

Potential Solution #2: Restore NuGet Packages

There's a right-click option on .sln files called "Restore NuGet Packages". This was the first thing I attempted to do while trying to fix this problem. Unfortunately, it didn't help, because all I got was this:

"All packages are already installed and there is nothing to restore." Which is not helpful in the least.

Potential Solution #3: Use the NuGet UI

The next thing I could think to do was use the NuGet UI within Visual Studio to reinstall all the packages. Problem is, there is approximately (counts on fingers) 57 jillion packages on this solution. Refreshing them using the UI would take a lot of time.  

Clearly I was not going to do this. I needed something a bit more... forceful. Which is when I stumbled upon the actual, final solution that restored Intellisense and fixed Go To Definition...

Actual Solution: Delete Local NuGet Packages

...I deleted my local copy of this solution's NuGet packages.

At the root of our solution there is a packages folder.  I deleted the entire contents of this folder.  Upon reopening Visual Studio, Intellisense and Go To Definition were restored to full working order.

Another stupid problem solved!

If I'm being completely honest, I do not know exactly why this works. After all, Visual Studio showed errors on references which should exist on my local machine, not in NuGet packages. But at this point, I don't particularly care why it works, I'm just glad it does.

Summary

It turned out the issue was related to NuGet; what I needed to do was delete the contents of the packages folder. For completeness's sake, here's the steps to do what I did.

  1. Close all instances of Visual Studio 2019.
  2. Delete the contents of the packages folder at the root of your solution on your local machine.
  3. Open Visual Studio 2019 again.

This final solution worked for me. I am including the potential solutions in this post in the hopes that one of them (actual or potential) works for you, dear reader. Let me know if you have any other solutions in the comments!

Happy Coding!