我正在使用WUApiLib.dll,并编写程序来检测可以下载和安装哪些更新。无法将COM对象转换为接口类型'WUApiLib.UpdateSession c#
Type t = Type.GetTypeFromProgID("Microsoft.Update.Session", "10.81.4.213");
UpdateSession session = (UpdateSession)Activator.CreateInstance(t);
ISearchResult SearchResults = UpdateSearchResult.Search("IsInstalled=0");
foreach (IUpdate x in SearchResults.Updates)
{
Console.WriteLine(x.Title);
}
大部分作品完美,但在某些情况下,我得到一个错误的铸造UpdateSession时间:
UpdateSession session = (UpdateSession)Activator.CreateInstance(t);
,出现以下错误:
{"Unable to cast COM object of type 'System.__ComObject' to interface type 'WUApiLib.UpdateSession'.
This operation failed because the QueryInterface call on the COM component for the interface
with IID '{918EFD1E-B5D8-4C90-8540-AEB9BDC56F9D}' failed due to the following error:
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)."}
我没有配置防火墙,因为我看到有人在类似的错误的其他主题中说,但我不知道为什么我得到这个错误。 任何想法是什么问题以及我如何解决它?
RPC服务正在运行,到目前为止我没有运行防火墙。没有连接问题。 –