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

5

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.

asp.net-mvc
nuget
visual-studio-2017
asked on Stack Overflow Oct 11, 2017 by Alim • edited Oct 11, 2017 by Alim

4 Answers

5

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.

answered on Stack Overflow Aug 1, 2019 by Angel Venchev
1

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

answered on Stack Overflow Oct 11, 2017 by Alim
0

I had this problem with a log4net version on a build server. After backing up the local source folder I removed it, then started up visual studio, went to the Source Control Explorer, found my solution and went to Check out for Edit.

check out for edit

Once I had a new local copy of latest version, had to go to the directory on disk and replace the log4net package.

directory

Then go back to visual studio, and build the solution, which built ok now. Then check everything in again, and the build server was fixed.

answered on Stack Overflow Nov 13, 2020 by rupweb
-2

It can be happen when you create a Project in upper version Visual Studio and working in lower version Visual Studio.

Check which version Visual Studio you create your project and now working in which version Visual studio.

Try it on latest version Visual Studio.

answered on Stack Overflow Feb 1, 2018 by Aminur Rahman

User contributions licensed under CC BY-SA 3.0