Administrators AWS Posted April 29, 2013 Administrators Posted April 29, 2013 Hello, [OS Version: Windows XP Professional 5.1.2600 Build: xpsp.sp3.gdr.101209-1647 Service Pack 3] I am trying to Scan for Available patches offline(with wsusscan.cab) on Windows XP using wuapi.dll in C#. Below is the code UpdateSessionClass updateSession = new UpdateSessionClass() IUpdateServiceManager updateServiceManager = updateSession.CreateUpdateServiceManager() IUpdateService updateService = updateservmanager.AddScanPackageService("Offline Sync Service", CabFilepath, 0) IUpdateSearcher updateSearcher = updateSession.CreateUpdateSearcher() updateSearcher.ServerSelection = ServerSelection.ssOthers updateSearcher.ServiceID = updateService.ServiceID ISearchResult searchResult = updateSearcher.Search("IsInstalled=0 or IsInstalled=1") This code works fine on other Windows XP versions and Windows 7. The issue is with this particular build xpsp.sp3.gdr.101209-1647. All the dlls on this machine are old. They have not been updated. So it is still using wuapi.dll from 2008. Initially when I ran this code, I got an Exception Unable to cast COM object of type 'WUApiLib.UpdateSessionClass' to interface type 'WUApiLib.IUpdateSession3'. 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: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at WUApiLib.UpdateSessionClass.CreateUpdateServiceManager() To resolve this issue, I unregistered the existing wuapi.dll that is in System32 folder and then replaced that dll with newer version of wuapi.dll and registered it again. This time I was able to create "UpdateServiceManager" but threw an exception at AddScanPackageService(). The Exception is Specified cast is not valid. at WUApiLib.UpdateServiceManagerClass.AddScanPackageService(String serviceName, String scanFileLocation, Int32 flags) I am not able to get any more information on that exception. Also, I have no idea why the cast is not valid. Do I have to replace any other dlls like I did with wuapi.dll? What am I missing here? Any help would be greatly appreciated. Thank you. [note: I cannot upgrade my OS. I have to work with this version and build] View this thread
Recommended Posts