c# - NotSupportedException when doing a Bing image search programatically -
i using following code more 50 results bing image search using bing search container bing api. problem when try , execute query (query.excecute()
) after changing off-set next 50 results ("$skip", 50)
following error:
a first chance exception of type 'system.notsupportedexception' occurred in microsoft.data.services.client.dll
i can't figure out how query. re-iterate occurs when when loop executes second time. happens on line var results = query.execute();
, when tries query.
void bingsearch(string searchterm) { try { imageset = new list<bing.imageresult>(); const string bingkey = "[key]"; var bing = new bingsearchcontainer( new uri("https://api.datamarket.azure.com/bing/search/")) { credentials = new networkcredential(bingkey, bingkey) }; var query = bing.image("\"" + searchterm + "\"" + "(" + site1 + ")", null, null, null, null, null, imagefilters); debug.print("full search: " + query.tostring()); int length = 3; int resultspage = 0; (int = 0; < length; i++) { query = query.addqueryoption("$top", 50); query = query.addqueryoption("$skip", resultspage); var results = query.execute(); int index = 0; foreach (var result in results) { imageset.add(result); debug.print("url: " + imageset[index].title); index++; } resultspage = resultspage + 50; debug.print("getting next page: " + resultspage); } debug.print("results: " + imageset.count); } catch { debug.print("error"); } }
Comments
Post a Comment