我正在使用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服務正在運行,到目前爲止我沒有運行防火牆。沒有連接問題。 –