Click here to Skip to main content
15,881,938 members
Articles / All Topics

The Path is Null and Full of Squiggles

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
5 Apr 2017CPOL3 min read 5.1K   1  
This post will discuss Lightweight Solution Load in Visual Studio 2017

The Path is Null and Full of Squiggles

I've been using Visual Studio 2017 since the earliest bits were available and I can confidently say, I'm a fan and highly recommend you give it a shot if you get a chance.

With that being said, sometimes new features can cause things to blow up and this post is going to be discussing one of those such features, namely Lightweight Solution Load.

The Terrifying Null Path Error

Recently, I opened up a decently sized solution (~9 projects) and everything seemed in order. All of my dependencies were there, with no warning signs to be seen:

The Path is Null and Full of Squiggles

Then I actually opened up a code file and was bombarded with red squiggles:

The Path is Null and Full of Squiggles

Bizarre. Visual Studio clearly recognizes all of the dependencies and that they exist within the project, but the actual code doesn't acknowledge them at all.

Let's try a few things:

  • Try a dotnet restore - Hoping that this was just some bizarre UI issue and that the packages weren't in fact loaded.
  • Restart Visual Studio - Sometimes, you just need a good ole' restart to get things back on track.
  • Restart Local Machine - I don't nearly restart as often as I should, so perhaps something got out of whack (i.e., user settings, VS settings, etc.)

Nothing, none of these worked - at all. So, I simply tried building the project and as you might expect, yet another plethora of 200+ error messages like these:

The type or namespace name 'Microsoft' could not be found 
(are you missing a using directive or an assembly reference?)

And:

The type or namespace name 'System' could not be found 
(are you missing a using directive or an assembly reference?)

And we certainly can't go having basic primitive types either:

Predefined type 'System.String' is not defined or imported

After digging around in the Build Output window, I noticed the following message:

Build started ...  
Build Failure. Error: 'path' cannot be an empty string ("") or start with the null character.  
Parameter name: path  
========== Build: 0 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Now we were getting to the bottom of things, now let's see if we can use this to actually resolve the issue.

The Cause: Lightweight Solution Load

After a bit of research into this issue, I came across a Visual Studio Community Issue that detailed the same basic behavior and error message and it revealed the culprit: Lightweight Solution Load.

If you aren't familiar with Lightweight Solution Load, it's a great feature within Visual Studio 2017 and can make Visual Studio feel much snappier and responsive, especially when working on large projects. It essentially loads all of the projects asynchronously, however attempting to access any particular one will prioritize its loading so you can get to the code you need quickly. Well - that's great and all, but if this occurs what's the point.

Anyways, back onto actually resolving the problem. So to fix this issue, simply disable Lightweight Solution Load for the solution and re-open it.

The Path is Null and Full of Squiggles

You'll quickly see after doing this that your dependencies are all loaded (and recognized) as expected:

The Path is Null and Full of Squiggles

A Few Potential Alternatives

The earlier discussion within the Visual Studio issues area had quite a few potential other fixes that may/may not work in all scenarios, but are worth giving a try if you really enjoy using the Lightweight Solution Load feature:

  • Deleting the .vs and temp directories
  • Clearing the NuGet Cache - via Tools > Options > Nuget

Your mileage may vary, but hopefully this helped guide you far, far away from all of those red squiggles.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
An experienced Software Developer and Graphic Designer with an extensive knowledge of object-oriented programming, software architecture, design methodologies and database design principles. Specializing in Microsoft Technologies and focused on leveraging a strong technical background and a creative skill-set to create meaningful and successful applications.

Well versed in all aspects of the software development life-cycle and passionate about embracing emerging development technologies and standards, building intuitive interfaces and providing clean, maintainable solutions for even the most complex of problems.

Comments and Discussions

 
-- There are no messages in this forum --