Visual Studio - Error when clicking on Solution ->

2019-01-11 21:22发布

问题:

When i try to access my solution Properties, i get the following error:

Object reference not set to an instance of an object

I am using VS 2012. What could be the cause of this?

回答1:

Some extensions may cause this. Try disabling extensions and restarting Visual Studio.

Quite often error will be gone even if you re-enable extensions after this.

There's a bug report on Microsoft Connect (link). It is marked there as "Closed as External", but it seems that it may occur randomly with any extension, so would be worth voting it there to bring it to Microsofts attention.



回答2:

In my case, the problem was solution-specific. NuGet was causing this error, but not the extension itself but a NuGet package that generated an error on VS load. When I opened NuGet Package Manager Console I saw a big red text with a description of the error. In my case it was T4Scaffolding.Core package, which in turn is a dependency of MVCMailer.

If this is your case, you will probably see what package generates an error in PM Console.



回答3:

I faced this dialog too and i'm not sure what exactly causes this as i couldn't even open the NuGet console to see detailed error messages.

Closing Visual Studio, deleting %AppData%\Microsoft\VisualStudio and restarting Visual Studio worked for me as it causes a reset of various things like window configurations.

I think if this dialog is displayed some files may be corrupt in %AppData%\Microsoft\VisualStudio and by deleting that folder Visual Studio can start normally again.

Update:

The issue arises on my machine when i start Visual Studio by using "run as administator" whereas Visual Studio has been started before without that option and %AppData%\Microsoft\VisualStudio had been created without the administator association.



回答4:

Visual Studio 2013: I had this issue when I tried opening TOOLS -> Extensions and Updates. I used @ViRuSTriNiTy idea, but only cleaned the files from: C:\Users[myUserName]\AppData\Local\Microsoft\VisualStudio\12.0\Extensions There are 2 cache files over there. Deleted them and restarted VS2013 and it was fixed



回答5:

The way it was happening for me might be unique to me/my setup, but I'd love to know if anyone else has this happen, and if they find out why:

  • If I launch an .sln file by double-clicking it, it will load VS and I can right-click the Solution and get Properties to come up no problem.
  • If I go to "Open Project" on the Visual Studio welcome page or from File > Open > Project/Solution, navigate to the .sln file and launch it by selecting it and clicking "Open" in the File dialog, that's when I have this issue.

I'm going to just always launch the .sln file from now on, but I'd love to know why this happens when using "Open Project" from the welcome page or from File > Open > Project/Solution! I tried going into Tools > NuGet Package Manager > General and I unchecked the options for allowing NuGet to download missing packages and Skip applying binding redirects, and under Package Sources I de-selected the checkboxes (my dev machine does not connect to the internet). Environment > Extensions and Updates: I tried it with and without "Load per user extensions when running as administrator" and running it as an Admin and without running as Admin. Also tried just deleting everything at C:\Users\me\AppData\Local\Microsoft\VisualStudio. No change from those 2 bullets above.