Reputation: 6962
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".
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.
Upvotes: 15
Views: 26713
Reputation: 1006
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
Upvotes: 0
Reputation: 2198
For me, the solution was as simple as updating Visual Studio via notifications.
Upvotes: 0
Reputation: 385
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.
Upvotes: 0
Reputation: 1
This worked for me.
Upvotes: 0
Reputation: 353
I got the same error working with c++. I did V.S. uninstall and then install. Then everything went well. Regards.
Upvotes: 0
Reputation: 1557
In my case, it was because I was using IIS (not IIS Express) and didn't run Visual Studio 2017 as Administrator.
Upvotes: 0
Reputation: 695
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
Upvotes: 0
Reputation: 11
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.
Upvotes: 1
Reputation: 29579
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.
Upvotes: 37
Reputation: 54979
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.
Upvotes: 1
Reputation: 6962
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.
Upvotes: 5