Visual Studio 2017: "Object reference not set to an instance of an object" while loading the project

23,043

Solution 1

For me on Visual Studio 2017, none of the suggestions worked. What worked was shutting down all Visual Studio instances and wiping away the .vs folder in the solution root.

Solution 2

I've managed to get it fixed. Not sure that it's brilliant solution, but better than nothing.

I've removed the line below from the failed project's .csproj file after dozens of random tests.

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

Now it loads correctly and it seems to be working well.

Btw, honestly I have no idea what does this line mean and will appreciate someone who can explain why is getting rid of that line fixes the issue and basically why this line is needed.

Solution 3

My symptoms were that all the class libraries in my solution were loading correctly but the MVC project was failing to load with the error message in the question.

Running Visual Studio as administrator fixed the problem for me.

Share:
23,043
Artyom Pranovich
Author by

Artyom Pranovich

Passionate software developer and just a cool guy! :D http://www.linkedin.com/in/apranovich

Updated on July 05, 2022

Comments

  • Artyom Pranovich
    Artyom Pranovich almost 2 years

    I have a project inside the VS solution that loads correctly in VS2015, but it seems to be corrupted in VS2017 (RC2).

    In the solution explorer it shows that its "load failed" and when I try to reload it I receive an error popup with the message "Object reference not set to an instance of an object".

    enter image description here

    I thought that it might be because VS2017 changed somehow .csproj file automatically for their needs, but after compare it with the version within VS2015 solution I found out that they are not different.

    Have anyone experienced something like that? And how it's possibly can be fixed?

    Thanks.

  • Jared Beach
    Jared Beach over 5 years
    I should have known
  • Chandan
    Chandan over 5 years
    Same issue , re install did not work . Still seeing other options
  • fr0ga
    fr0ga over 3 years
    Worked for my project after conflicted merge