Introduction to Data Binding in Silverlight 3 with CTP2 - An error occurred while processing this request. RRS feed

  • Question

  • Uri _SERVICE_URI = new Uri("http://localhost:4716/ADONetDataServiceTest/NWWebDataService.svc/");
    NorthwindEntities nwsvc = new NorthwindEntities(_SERVICE_URI);
    object userState = null; var pLinqQuery = (from p in nwsvc.CreateQuery<Products>("Products") orderby p.ProductName ascending select p) as DataServiceQuery<Products>; pLinqQuery.BeginExecute( (asResult) => { Dispatcher.BeginInvoke( () => { var IEnumerableOfPublications = pLinqQuery.EndExecute(asResult); // An error occurred while processing this request DataContext = IEnumerableOfPublications.ToList(); }); }, userState); in browser query ->
    work well.

    in silverlight app - An error occurred while processing this request. WHY????
    NorthwindEntities nwsvc = new NorthwindEntities(_SERVICE_URI);
    var q = from c in nwsvc.Categories.Skip(2) select c;
    foreach (var item in q) { }<span style="color:green">// Specified method is not supported.</span>
    in WPF app work done. Specified method is not supported - WHY???
    Friday, September 18, 2009 2:01 PM


  • Hi,

    Silverlight only supports asynchronous execution of queries (as it only supports asynchronous network APIs).
    The "var q = from c in nwsvc.Categories.Skip(2) select c" creates a "query description". Now if you just do foreach on it, it would need to sychronously execute such query (to be able to provide you with the resuls). That is not possible in Silverlight. So we fail with the exception above. (If you could post the callstack of the exception I would be able to verify that for sure).

    To make this work you would need to cast the q to a DataServiceQuery and call BeginExecute on it. And then in the callback call EndExecute which will return the results. Exactly like you do in the first half of your question.

    As for the "An error occured while processing this query.", we would need to see more information. Look at the exception object you get, it usually has an InnerException filled which contains the true reason for the failure. Also a callstack of that exception would help us identify where it went wrong.
    You may also try to get some kind of network trace to see what URI got requested and if the server actually replied and with which response.

    Vitek Karas [MSFT]
    • Marked as answer by edhickey Friday, September 25, 2009 8:55 PM
    Tuesday, September 22, 2009 3:11 PM