I am using WUApiLib.dll, and writing a program to detect 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 perfectly, but in some cases I am getting an error in the casting to 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 dont have firewall configured, as I saw people say in other topics regarding similar error, but I have no idea why I am getting this error. any idea what is the problem and how I can solve it?