Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet: Error HRESULT E_FAIL has been returned from a call to a COM component

When I try to add a new package with NuGet I get the error

Error HRESULT E_FAIL has been returned from a call to a COM component.

I've checked several posts about this and tried alot of solutions but can't seem to find the issue. It might be worthing noting that I moved and renamed my project at some point and the copy I left behind still functions with NuGet packages.

After looking into it some more I found this error:

System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. at EnvDTE.SourceControl.CheckOutItem(String ItemName)

What I've tried already:

  • Deleting the user.csproj and/or .suo

  • Checking all project references and if they are located correctly

  • Deleting Temp files

  • Deleting bin & obj folders

  • Deleting the ProjectTemplatesCache

  • Checking the project web properties

  • Restarting VS, cleaning and rebuilding the project (always run in admin).

  • Deleting the ComponentModelCache

  • Deleting packages folder content and restoring NuGet packages in solution.

  • Check-in all pending changes to version control before attempting to add a new NuGet package.

like image 562
Alim Avatar asked Oct 11 '17 08:10

Alim


2 Answers

I just had this 01.08.2019 with both Visual Studio 2019 and Visual Studio 2017. I've tried the following solutions which did not work:

  1. https://social.msdn.microsoft.com/Forums/officeocs/en-US/4eea5785-0a83-4389-89e3-209a5a4432c0/referencemanagerpackage-fails-to-install-vs-2017-community-edition?forum=vssetup
  2. Error HRESULT E_FAIL has been returned from a call to a COM component on Add Reference

What worked for me is simply deleting the .vs folder and also deleting everything from the packages folder of the solution I was using. Then I ran Restore NuGet Packages on the solution level.

like image 129
Angel Venchev Avatar answered Oct 24 '22 09:10

Angel Venchev


Checking in all pending changes and then performing a 'check-out for edit now' did the trick.

like image 25
Alim Avatar answered Oct 24 '22 07:10

Alim