Error HRESULT E_FAIL
Error HRESULT E_FAIL is a common error in VS that Microsoft is yet to address/fix. A fix I found on Visual Studio 2019 Version 16.2.4 (Updated Aug 2019).
One day I was in a project and I needed to add a reference to the current project and when doing so was presented with the following error:
HRESULT E_FAIL has been returned from a call to a COM component
I followed every single post online on how to fix this issue but they were all the same, not one post helped. I tried everything from a reinstall, cleaning the registry, deleting folders from ProgramData/AppData/ .vs Folder or even Program Files (x86), yet none of the issues help.
These are the steps that I’ve taken to add a reference to a project, even though it gets added, if I try to add a reference by right clicking and choosing the add reference I still get the same error!
-
-
-
-
- Press and Hold the following sequence in VS2019 Cntrl+Alt+J
- This opens the Object Browser
- Reviewing the image below click on the dots below the yellow dot
-
-
-
- You will now see a window that says Edit Custom Component Set
- All you need to do in the browse section is choose the reference
- Once you’ve specified the reference click on Add
- Now you’ve to click on Projects next to browse
- In this step all you need to do is click on Add again and then press ok
- You will now see in the list the reference you’ve added to your project and the name of your project.
- For the last step all you need to do is select the reference that you just added
- Now press the button below the red dot in the image below
- Add to References in Selected Project in Solution Explorer
- You will now get a message that you’ve added the reference to your current project, that’s it.
Summary
Even after going through all of those steps, if you still try and right click to add a reference, you still get the Error HRESULT E_FAIL has been returned from a call to a COM component error. I am surprised that after all this time Microsoft hasn’t fixed this issue. But the fix works from the current version. I did try using previous versions but since this is the latest I opted to use VS2019 instead.