使用VS2019添加引用错误,提示“Error HRESULT_FAIL has been returned from a call to a COM component.”

1、错误提示的内容
使用VS2019添加引用错误,提示“Error HRESULT_FAIL has been returned from a call to a COM component.”

2、解决的方法

(1)运行 VS2019的开发人员命令提示符。
使用VS2019添加引用错误,提示“Error HRESULT_FAIL has been returned from a call to a COM component.”

(2)进入VS2019安装目录的通用程序集,其中框出的部分为VS IDE的版本,这个需要根据你具体的版本来
栗子:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies
使用VS2019添加引用错误,提示“Error HRESULT_FAIL has been returned from a call to a COM component.”使用VS2019添加引用错误,提示“Error HRESULT_FAIL has been returned from a call to a COM component.”

(3)输入命令:gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll(该命令用于将程序集加入全局缓存当中)。

(4)退出VS2019,再进入。

(5)重新添加引用,正常。

【引用】

a.使用 Gacutil.exe 将.Net程序集添加到GAC的方法
1、使用gacutil.exe工具安装:gacutil -i “要注册的dll文件全路径”。
2、"gacutil.exe”工具为.NET自带工具 ,需要注意的是:这个工具在.NET Framework 运行时中并不包含。他是SDK的一部分。 例如在 .NET Framework 2.0 时,我们就要单独下载 .NET Framework 2.0 SDK,或者装了 Visual Studio 后才会具有这个工具。

b.VS2019添加引用时“未能正确加载ReferenceManagerPackage包”以及“COM组件调用返回错误HRESULT E_FAIL”

c.vs2017添加引用报错 对COM组件的调用返回了错误HRESULT E_FAIL