locked
HTTP Stack Exception using WCF DS Client (PCL) in Silverlight RRS feed

  • Question

  • Here's the error:

    {System.NotSupportedException: Silverlight Browser Http Stack is not supported on the Portable Library, only Client Http is supported.
       at System.Data.Services.Client.HttpWebRequestMessage.EndGetResponse(IAsyncResult asyncResult)
       at System.Data.Services.Client.ODataRequestMessageWrapper.EndGetResponse(IAsyncResult asyncResult)
       at System.Data.Services.Client.DataServiceContext.GetResponseHelper(ODataRequestMessageWrapper request, IAsyncResult asyncResult, Boolean handleWebException)
       at System.Data.Services.Client.DataServiceContext.EndGetResponse(ODataRequestMessageWrapper request, IAsyncResult asyncResult)
       at System.Data.Services.Client.RequestInfo.EndGetResponse(ODataRequestMessageWrapper request, IAsyncResult asyncResult)
       at System.Data.Services.Client.QueryResult.AsyncEndGetResponse(IAsyncResult asyncResult)}

    The steps are as follows:

      1. Create EF6 model

      2. Create EF WCF DS Service

      3. Create PCL Service Reference

      4. Create Silverlight App w/PCL references


    http://www.technicalmedia.com

    Sunday, December 29, 2013 10:54 AM

Answers

  • Figured it out !!! :) :) :)

    You can set browser or client http handling in Silverlight. 

    The highlighted code sets Silverlight to use client http handling - then the portable class libraries are happy and there's no complaining (in the form of an exception).

    Also note that it is important to switch back to the UI thread before setting the data context (also highlighted).

    This link pointed me in the right direction and compares browser and client http handling as well as showing how to properly set which you want to use: http://msdn.microsoft.com/en-us/library/dd920295(v=vs.95).aspx

    Love it !!!!!!


    http://www.technicalmedia.com



    • Marked as answer by Mike Graham Tuesday, December 31, 2013 12:28 PM
    • Edited by Mike Graham Tuesday, December 31, 2013 12:37 PM
    Tuesday, December 31, 2013 12:28 PM

All replies

  • Note:  if I create a Silverlight project (instead of a PCL project) for the OData service reference and use the Silverlight versions of the client assemblies, everything works great.  I know I should move on, but I'm very stubborn and also I really like the idea of one client project :)


    http://www.technicalmedia.com

    Sunday, December 29, 2013 11:11 AM
  • Hello,

    >>System.NotSupportedException: Silverlight Browser Http Stack is not supported on the Portable Library, only Client Http is supported.

    When using HttpClient from a Silverlight application many http headers are not supported and will result in an ArgumentException or NotImplementedException when set and calling HttpClient methods that send a request.

    Resolution

    For a list of headers which are not supported in Silverlight please see:

    http://msdn.microsoft.com/en-us/library/system.net.webheadercollection(v=vs.95).aspx

    http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.headers(v=vs.95).aspx

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 30, 2013 2:25 AM
    Moderator
  • Hi Fred.  Thanks for the response :)

    Wouldn't that consideration need to be addressed in the portable implementation of System.Data.Services.Client.DataServiceContext in the Microsoft.Data.Services.Client.Portable assembly?

    I believe that the DataServiceContext is the one issuing the web requests.


    http://www.technicalmedia.com

    Monday, December 30, 2013 12:08 PM
  • Hi Mike,

    >>Wouldn't that consideration need to be addressed in the portable implementation of System.Data.Services.Client.DataServiceContext in the Microsoft.Data.Services.Client.Portable assembly?

    What version are you using? If you are WCF Data Service 5.6.0, all of the client-side libraries now have portable library support. This means that we can now use the new JSON format in Windows Phone and Windows Store apps.

    Se it here:

    http://www.nuget.org/packages/Microsoft.Data.Services.Client/

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, December 31, 2013 9:04 AM
    Moderator
  • Thanks for the response, Fred :)

    I'm using the WCF Data Services 5.6 portable class libraries (obtained via nuget) - that's what i'm posting about.  

    If you look at the screen shots in the first post, you will see references to the .portable WCF Data Services 5.6 assemblies:

    • Microsoft.Data.Edm.Portable
    • Microsoft.Data.OData.Portable
    • Microsoft.Data.Services.Client.Portable and
    • System.Spatial.Portable

    In the Microsoft.Data.Services.Client.Portable, there is a class: System.Data.Services.DataServiceContext that does the HTTP interaction with the OData service.

    I am requesting help to get this configuration working in Silverlight :)

    I believe that the System.Data.Services.DataServiceContext class is generating the exception described in the first post.

    Thanks again,

    -Mike Graham


    http://www.technicalmedia.com

    Tuesday, December 31, 2013 12:04 PM
  • Figured it out !!! :) :) :)

    You can set browser or client http handling in Silverlight. 

    The highlighted code sets Silverlight to use client http handling - then the portable class libraries are happy and there's no complaining (in the form of an exception).

    Also note that it is important to switch back to the UI thread before setting the data context (also highlighted).

    This link pointed me in the right direction and compares browser and client http handling as well as showing how to properly set which you want to use: http://msdn.microsoft.com/en-us/library/dd920295(v=vs.95).aspx

    Love it !!!!!!


    http://www.technicalmedia.com



    • Marked as answer by Mike Graham Tuesday, December 31, 2013 12:28 PM
    • Edited by Mike Graham Tuesday, December 31, 2013 12:37 PM
    Tuesday, December 31, 2013 12:28 PM