Saturday, November 23, 2019

Missing A Project/Assembly Reference

I have several solutions that need to reference assemblies in another solution. For many years, I used assembly/DLL references, because the other solution is our "Core Framework" solution, and I didn't want other programmers messing around with our framework classes. At another company that I worked at, that happened all too often. Then I'd have to go back in and fix all the bugs they put into *my* Framework classes!!! Without the projects being in the solution, it wasn't as likely that someone would go in and mess around with those classes.

But assembly references can cause issues too (such as outdated assemblies and problems with automated Builds, to name just two). So I finally relented and started adding the necessary Core Framework projects to each new solution and then any new projects for that solution could have project references to the Framework instead of assembly references. All was well for a while, but then several months ago, the problems began.

In a new solution that included Framework projects, I started getting "red squigglies" everywhere for one particular Framework project, showing the usual error when I moused over: "blah blah blah does not exist (are you missing an assembly reference?)". None of the other Framework projects have had problems, only this one. The using directive for that project's namespace had the squiggly and any class that was in that namespace also had squigglies. And Intellisense wouldn't work for any method calls, etc. And here's the weird part: with all those errors, everything still built fine on my computer (and on the Build server)!!

I'm using Visual Studio 2017. I was at version 15.8.something, which was not the latest version. So, I thought that I needed to update (because nobody else had the problem), so I'm now at the latest version (15.9.17) and it did NOT help! =0(

Googling for "Visual Studio 2017 missing project references" offered all kinds of suggestions. Clean the solution and build. Clean the solution and rebuild. Delete the obj folder and reopen VS. Add dependency references. Remove the project and add it back in. Remove the reference and add it back in. And many more that I don't even remember right now ... none worked!!!

I would periodically, drop my search for a fix and continue working for a while. Until the fact that I had no Intellisense started driving me nuts again and I'd search some more. This went on like this for months. Until I finally found something that worked!!!

Someone on some Forum (StackOverflow, I think) suggested unloading the problem project. The red squigglies suddenly disappeared! And Intellisense was back! The project reference is still there (because unloading doesn't affect the .sln at all, which is nice because I don't have to worry about checking it into source control, since there's no change, and it won't affect any of the other developers).

All you have to do is right-click the offending project in the Solution Explorer and choose "Unload Project" (it's down towards the bottom of the menu). The project remains displayed in the solution, but is marked as "(unavailable)". If you need to, you can always right-click it again and choose "Reload Project".

I have no idea why this works (I tried to Google to find an answer to that question), but after trying off-and-on for months to find a solution to my problem, I'm not going to "look a gift horse in the mouth", as they say!

Now I can continue with my Happy Coding! =0)


  1. Hi Bonnie,
    Very interesting.
    Thank you for sharing your experience with others :)


    1. Thanks for your nice comment, Vojislav! =0)