Why does NuGet fail to load in Visual Studio 2012

2020-06-09 06:23发布

问题:

After updating to Visual Studio 2012 Update 3 (I was previously running Update 2), NuGet fails to load. By that I mean the Package Manager no longer shows up after I have loaded a solution that uses NuGet and used to work. * It does not show up under the Tools Menu. * NuGet (Manage NuGet Packages) does not show up in the menu after right click on the solution * NuGet (Manage NuGet Packages) does not show up in the menu after right click on the project

The Extensions and Updates dialog (TOOLS/Extensions and Updates...) does show the NuGet Package Manager as installed and when I click on it it shows that it can be uninstalled.

Also when I checked the installation log after uninstalling and then re-installing the NuGet Package Manager (from the download I got on the CodePlex nuget site) it shows that it was successfully installed:

 /10/2013 11:39:05 AM - Beginning to install extension to Microsoft Visual Studio Professional 2012...
7/10/2013 11:39:05 AM - Install to Microsoft Visual Studio Professional 2012 completed successfully. The extension has been installed to C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\\COMMON7\IDE\EXTENSIONS\VYALGTD2.XZS\

I checked and this folder does in fact exist and contains NuGet dlls.

When I go to the TOOLS/Options... dialog and select Package Manager the right hand pane shows the text: "An error occurred loading this property page". The same text is shown when Package Manager is expanded and either General or Package Sources are selected.

I have uninstalled and re-installed NuGet numerous times and I have installed both from the downloaded VSIX and directly in the Extensions and Updates dialog and the result is always the same.

I have installed an older version of NuGet and I get the same results. I have uninstalled Visual Studio and re-installed it and I get the same results with version 1, Update 2, or Update 3.

The Activity.log.xml file shows the following issue when attempting to load NuGet:

<entry>
  <record>211</record>
  <time>2013/07/10 17:39:44.295</time>
  <type>Information</type>
      <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
<description>Successfully loaded component assembly from cache</description>
<path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\EXTENSIONS\VYALGTD2.XZS\NuGet.VisualStudio.dll</path>
</entry>
<entry>
  <record>212</record>
  <time>2013/07/10 17:39:44.295</time>
  <type>Information</type>
  <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
  <description>Successfully loaded component assembly from cache</description>
  <path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\EXTENSIONS\VYALGTD2.XZS\NuGet.Console.dll</path>
</entry>
<entry>
  <record>213</record>
  <time>2013/07/10 17:39:44.295</time>
  <type>Information</type>
  <source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
  <description>Successfully loaded component assembly from cache</description>
  <path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\EXTENSIONS\VYALGTD2.XZS\NuGetConsole.Host.PowerShellProvider.dll</path>
</entry>
<entry>
  <record>214</record>
  <time>2013/07/10 17:39:44.298</time>
  <type>Information</type>
  <source>VisualStudio</source>
  <description>End package load [Visual Studio Component Model Host Package]</description>
  <guid>{49D12072-378B-4FFA-A09E-40E0B5D097CC}</guid>
</entry>
<entry>
  <record>215</record>
  <time>2013/07/10 17:39:44.383</time>
  <type>Information</type>
  <source>VisualStudio</source>
  <description>End package load [Microsoft.VisualStudio.Editor.Implementation.EditorPackage]</description>
  <guid>{E269B994-EF71-4CE0-8BCD-581C217372E8}</guid>
</entry>

This part looks OK. But then there are the following warnings and errors:

<entry>
  <record>234</record>
  <time>2013/07/10 17:39:57.070</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{00000000-0000-0000-0000-000000000000} LANG:0409 ID:1003&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>235</record>
  <time>2013/07/10 17:39:57.072</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{00000000-0000-0000-0000-000000000000} LANG:0409 ID:1004&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>236</record>
  <time>2013/07/10 17:39:57.073</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:101&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>237</record>
  <time>2013/07/10 17:39:57.073</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:106&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>238</record>
  <time>2013/07/10 17:39:57.073</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:102&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>239</record>
  <time>2013/07/10 17:39:57.073</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:101&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>240</record>
  <time>2013/07/10 17:39:57.074</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:107&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>241</record>
  <time>2013/07/10 17:39:57.074</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:103&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>242</record>
  <time>2013/07/10 17:39:57.074</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:105&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>243</record>
  <time>2013/07/10 17:39:57.074</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Performance warning: String load failed. Pkg:{5FB7364D-2E8C-44A4-95EB-2A382E30FEC7} (EditorExtensionsPackage) LANG:0409 ID:104&#x000D;&#x000A;</description>
</entry>
<entry>
  <record>244</record>
  <time>2013/07/10 17:40:00.908</time>
  <type>Information</type>
  <source>VisualStudio</source>
  <description>Entering function CVsPackageInfo::HrInstantiatePackage</description>
  <guid>{5FCC8577-4FEB-4D04-AD72-D6C629B083CC}</guid>
</entry>
<entry>
  <record>245</record>
  <time>2013/07/10 17:40:00.908</time>
  <type>Information</type>
  <source>VisualStudio</source>
  <description>Begin package load [NuGet.Tools.NuGetPackage, NuGet.Tools, Version=2.6.40627.9000, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]</description>
  <guid>{5FCC8577-4FEB-4D04-AD72-D6C629B083CC}</guid>
</entry>
<entry>
  <record>246</record>
  <time>2013/07/10 17:40:00.915</time>
  <type>Error</type>
  <source>VisualStudio</source>
  <description>CreateInstance failed for package [NuGet.Tools.NuGetPackage, NuGet.Tools, Version=2.6.40627.9000, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]</description>
  <guid>{5FCC8577-4FEB-4D04-AD72-D6C629B083CC}</guid>
  <hr>80070002</hr>
  <errorinfo>Could not load file or assembly 'NuGet.Tools, Version=2.6.40627.9000, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</errorinfo>
</entry>
<entry>
  <record>247</record>
  <time>2013/07/10 17:40:00.915</time>
  <type>Error</type>
  <source>VisualStudio</source>
  <description>End package load [NuGet.Tools.NuGetPackage, NuGet.Tools, Version=2.6.40627.9000, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]</description>
  <guid>{5FCC8577-4FEB-4D04-AD72-D6C629B083CC}</guid>
  <hr>80004005 - E_FAIL</hr>
  <errorinfo>Could not load file or assembly 'NuGet.Tools, Version=2.6.40627.9000, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</errorinfo>
</entry>
<entry>
  <record>248</record>
  <time>2013/07/10 17:40:00.915</time>
  <type>Warning</type>
  <source>VisualStudio</source>
  <description>Package failed to load; error message suppressed by skip flag</description>
  <guid>{5FCC8577-4FEB-4D04-AD72-D6C629B083CC}</guid>
</entry>
<entry>

With the main clue being in record 246 -- Could not load file or assembly 'NuGet.Tools, Version=2.6.40627.9000, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

The question is why can't the system find the file or what dependency is missing. MSDN Tech support was helping me, but then decided that this was a problem they would not support and that I should post the issue here.

回答1:

Take a look at this link to coops007 has a great solution for NuGet problem.

here are the steps to solve the issue, which worked for @Catherine:

  1. Download the Nuget vsix package from the web, not via the VS extension gallery in VS2012.
  2. Ensure VS2012 is fully closed.
  3. Run the VSIX installer twice (both at the same time!) The first will install, and the second says it is already installed. It is the second installer that actually finshes the job.

Note, if you run the installer just once, the errors inside VS2012 remain. Also, if you rerun the installer again, the errors remain. You have to run the installer twice simultaneously



回答2:

This scenario works for me:

  • Download NuGet Package Manager vsix file
  • Extract it like a zip archive
  • Copy the content to the folder where NuGet extension is installed (on my system it is "c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\oabo2crw.lk3")


回答3:

In case it helps . . .

I too had the Could not load file or assembly error for "NuGet.Tools". I am running Visual Studio Professional 2012 on Windows 8.1 and (after trying many other recommended solutions) the following steps worked for me:

  1. Ran VS2012 as administrator (at this point everything I did was as administrator...just in case)
  2. Uninstalled the NuGet Package Manager from the Extensions and Updates... dialog box found in the Tools menu.
  3. Restarted Visual Studio
  4. Downloaded the "Nuget.Tools.vsix" file from their website. You can find this by clicking on the more information link in package information section of the the Extensions and Updates... dialog box when the NuGet package is selected.
  5. Closed Visual Studio 2012.
  6. Ran powershell as administrator.
  7. Navigated to where I saved the .VSIX file.
  8. Ran the .VSIX file from powershell.

So essentially I just manually installed the package using powershell. After that, I just restarted Visual Studio and had no more errors.



回答4:

I am on Visual Studio 2015 Community edition and getting the same error. In my case, the issue got resolved by simply going to Tools > Extension and Updates and uninstalling "Nuget Package Manager for Visual Studio", restarting Visual Studio and then installing this extension again. Works perfectly with no errors now. Perhaps the installation routine was streamlined by now so that simply reinstalling resolved the issue.



回答5:

This killed me for a while. Ended up deleting the one whacky named folder in:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions 

Mine was qlpuoyw3.ayw and re-installing from the .vsix file. Worked like a champ. Also cleared up the same error with other extension.



回答6:

I solved this particular issue, but it just got me down the road to the next issue. Here is what I did to resolve this issue I hope it helps someone else:

  1. Uninstall Visual Studio 2012 (Control Panel - Program and Features - Microsoft Visual Studio Professional 2012)
  2. Delete the VS 2012 folders under Program Files and Program Files(x86). The actual name is Microsoft Visual Studio 11.0 (Very Poor that the uninstall does not remove the folders).
  3. Remove VS 2012 entries from Registry HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE (These will be the 11.0 entries under Visual Studio)
  4. Re-install Visual Studio 2012 (I get my version from an MSDN subscription download)

This fixed the problem I had with the Package Manager but I am left with a different problem where Web.Mvc.Package.MvcPackage does not load correctly and then my Solution will not longer recognize the project file for a solution I have because it indicates that it is incompatible. So I am back to uninstalling and removing all entries under Visual Studio 2012 (folders and registry) pertaining to MVC 4 and then re-installing again.