teeba
teeba

Reputation: 91

Error HRESULT E_FAIL has been returned from a call to a COM component on Add Reference

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

  1. add any reference and
  2. update my database through DB_First Approach

This issue started occuring after the last update of Windows.

Upvotes: 6

Views: 20725

Answers (5)

ephraim
ephraim

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

nickornotto
nickornotto

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

ardodiaz
ardodiaz

Reputation: 101

What worked for me

  1. Open the Developer Command Prompt for VS 2019 with admin privileges
  2. Type into the the Developer Command Prompt

cd C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies

Your path may differ so check

  1. Type into Developer Command Prompt

gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll

It should rebuild and you may now add references!

Upvotes: 10

Mihail Golden
Mihail Golden

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

teeba
teeba

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:

  1. Open "Developer Command Prompt for VS 2017" as Admin

  2. CD into "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies"

  3. Run "gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll" After that close and reopen "Developer Command Prompt for VS 2017" as Admin

  4. cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64"

  5. 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

Related Questions