Alim
Alim

Reputation: 337

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:

Upvotes: 6

Views: 13877

Answers (4)

rupweb
rupweb

Reputation: 3328

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.

Upvotes: 0

Angel Venchev
Angel Venchev

Reputation: 717

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.

Upvotes: 15

Aminur Rahman
Aminur Rahman

Reputation: 410

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.

Upvotes: -1

Alim
Alim

Reputation: 337

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

Upvotes: 1

Related Questions