C# & Windows Update Api (WUApiLib)
I am using Windows Update API (WUApiLib) in a C# .NET 2.0 project.
I get the following error on Windows XP (in Windows 7 it works alright):
"System.MissingMethodException: 开发者_StackOverflow社区Method not found: 'WUApiLib.UpdateSearcher WUApiLib.UpdateSessionClass.CreateUpdateSearcher()'."
This is my code:
WUApiLib.UpdateSessionClass session = new WUApiLib.UpdateSessionClass();
WUApiLib.IUpdateSearcher searcher = session.CreateUpdateSearcher();
WUApiLib.ISearchResult result = searcher.Search("Type='Software'");
if (result.Updates.Count > 0)
{
//do stuff
}
The error occurs at runtime, the compiler shows no errors...
Does anybody know why I get this error?
You are no doubt battling a version problem, the Win7 version is WUA version 2, XP is probably still stuck at 1. If you want to support XP then make sure to use an interop library that you generated with Tlbimp.exe on a XP machine. Keeps you out of trouble, you can't accidentally use an interface or method that isn't supported on XP.
I don't see much in the way of documentation for what's available in which version and to what degree version 2 is backwards compatible with version 1. Only this MSDN Library page seems relevant.
精彩评论