12

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.

Artyom Pranovich
  • 6,814
  • 8
  • 41
  • 60

11 Answers11

31

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.

Mahmoud Al-Qudsi
  • 28,357
  • 12
  • 85
  • 125
5

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.

Artyom Pranovich
  • 6,814
  • 8
  • 41
  • 60
1

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.

dannygb
  • 11
  • 2
0

Object reference not set to an instance of an object

That's a pretty crappy error message. It doesn't tell you anything about how to fix the problem. I think it may be akin to general protection fault or null pointer exception -- in other words only a software bug could explain such a failure to report a useful message (surely this is not "as designed"). A web search reveals that there could be many causes for this -- so prepare for a world of hurt (or better yet, give up now).

In my case, the fix was to install the expected version of the Windows 10 SDK as indicated by TargetPlatformVersion in the .csproj file.

Brent Bradburn
  • 51,587
  • 17
  • 154
  • 173
0

I removed the project from solution and reimported "existing project" into solution, then I saw a new error message: your project exists on both IIS EXPRESS and IIS , so I removed binding for this project (in my case : a website) in IIS and reimported the "existing project" csproj again, then it worked

Xavave
  • 645
  • 11
  • 15
0

In my case, it was because I was using IIS (not IIS Express) and didn't run Visual Studio 2017 as Administrator.

Michael Earls
  • 1,467
  • 1
  • 15
  • 25
0

I got the same error working with c++. I did V.S. uninstall and then install. Then everything went well. Regards.

0

This worked for me.

  1. Authenticate App pool with your account details
  2. Recycle App pool
  3. Stop and start
  4. Run a CMD command iisreset as an administrater.
deHaar
  • 17,687
  • 10
  • 38
  • 51
Mike
  • 1
0

I have started getting this issue after upgrading to Windows 10. I have gotten around it by simply repairing visual studio. It seems like this issue reappears after installing windows updates from my company.

N8ALL3N
  • 375
  • 1
  • 2
  • 14
0

For me, the solution was as simple as updating Visual Studio via notifications.

BoltKey
  • 1,994
  • 1
  • 14
  • 26
0

For Visual Studio 2022

I've managed to close the IDE and all instances related to it, restart the PC and run the Solution as Administrator.

Now I can access all the other files without any of the above error