Artyom Pranovich
Artyom Pranovich

Reputation: 6962

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

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.

Upvotes: 15

Views: 26713

Answers (11)

Rajaruban Rajindram
Rajaruban Rajindram

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

BoltKey
BoltKey

Reputation: 2198

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

Upvotes: 0

N8ALL3N
N8ALL3N

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

Mike
Mike

Reputation: 1

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.

Upvotes: 0

George Theodosiou
George Theodosiou

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

Michael Earls
Michael Earls

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

Xavave
Xavave

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

dannygb
dannygb

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

Mahmoud Al-Qudsi
Mahmoud Al-Qudsi

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

Brent Bradburn
Brent Bradburn

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

Artyom Pranovich
Artyom Pranovich

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

Related Questions