Reputation: 337
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.
Upvotes: 6
Views: 13877
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.
Once I had a new local copy of latest version, had to go to the directory on disk and replace the log4net package.
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
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:
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
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
Reputation: 337
Checking in all pending changes and then performing a 'check-out for edit now' did the trick.
Upvotes: 1