I use WUApiLib.dll and write a program to determine which updates can be downloaded and installed.
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); }
Most of the time it works fine, but in some cases I get an error message when releasing UpdateSession:
UpdateSession session = (UpdateSession)Activator.CreateInstance(t);
with the following error:
{"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)."}
I don’t have a firewall setting since I saw people talking on other topics regarding a similar error, but I have no idea why I get this error. any idea what the problem is and how can i solve it?
source share