While adding assembly reference in Visual Studio 2017, if you are facing the following error message: "Error HRESULT E_FAIL has been returned from a call to a COM component", this could be due to ReferenceManagerPackage failed to load. If you encountered this issue, here's a quick solution for you to resolve it.
If you are facing the error message: "Error HRESULT E_FAIL has been returned from a call to a COM component" while trying to add assembly references in your .NET project, follow the steps mentioned below:
- First of all, close all the instances of Visual Studio.
- Open the Developer Command Prompt for VS 2017 with admin privileges, as shown in the following screenshot:
- Now, navigate to the "C:\Program Files (x86)\Microsoft Visual Studio\2017\[EDITION]\Common7\IDE\PublicAssemblies" by entering the following command in the console window. Replace [EDITION] with the Visual Studio edition that you are using. It could be "Professional", "Enterprise" or "Community". If you are using Visual Studio 2017 Professional edition, the command will be:
CD "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies"
- Now enter the following commands, one after another:
gacutil /if Microsoft.VisualStudio.Shell.15.0.dll
gacutil /if Microsoft.VisualStudio.Shell.Interop.11.0.dll
- Once you get the Assembly successfully added to the cache message in the console window (as shown in the following screenshot), start the Visual Studio 2017 instance.
Now open your project and try to add the assembly reference. It will work this time. Do let me know on Twitter, if you are still facing the same problem.
Don't forget to checkout my books: Mastering Visual Studio 2019, Mastering Visual Studio 2017 and Windows Presentation Foundation Development Cookbook. You can find them at the following URL.