Reputation: 91
In VS-2017, on clicking "Add Reference" I am getting an error:
"Error HRESULT E_FAIL has been returned from a call to a COM component."
due to which I am unable to
This issue started occuring after the last update of Windows.
Upvotes: 6
Views: 20725
Reputation: 436
I had the same Error message UPON TRYING TO EDIT A USER CONTROL [SHIFT+F7].
I tried all previous answers and nothing helped.
In my case I had .cs files used by both, .Net, and .Net Framework [added as reference only]. Only after unloading the .Net Framework from solution - I managed to edit the .Net UI.
Upvotes: 0
Reputation: 2156
My issue happened when I tried to open newly cloned solution (that was previously developed in VS2019) in VS2022 and got lots of issues with missing references, most of them failing on AutoMapper
that was giving the above error. I copied the projects that had problem to build from a solution backup, rebuilt and all started working in VS2022.
Upvotes: 2
Reputation: 101
What worked for me
cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies
Your path may differ so check
gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll
It should rebuild and you may now add references!
Upvotes: 10
Reputation: 11
For VS Enterprise it works (run in developer command prompt): C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools\x64>gacutil.exe /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.11.0.dll
Upvotes: 1
Reputation: 91
This link helped me a lot:
Add a reference raise error: Error HRESULT E_FAIL has been returned from a call to a COM component
Steps:
Open "Developer Command Prompt for VS 2017" as Admin
CD into "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies"
Run "gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll" After that close and reopen "Developer Command Prompt for VS 2017" as Admin
cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64"
Run -> gacutil.exe /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.11.0.dll"
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.0 Copyright (c) Microsoft Corporation. All rights reserved. Assembly successfully added to the cache
Restarting your PC will solve the problem
Upvotes: 3