Propery Binding exception when bound to data received from the web socket RRS feed

  • Question

  • Hi,

    I am getting the following exception when I try to bind my properties to the data received from the MessageWebSocket. Works fine when the data is received from the normal StreamSocket.

    A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in System.dll
       at System.StubHelpers.EventArgsMarshaler.CreateNativePCEventArgsInstance(String name)
       at System.Runtime.InteropServices.WindowsRuntime.PropertyChangedEventArgsMarshaler.ConvertToNative(PropertyChangedEventArgs managedArgs)
       at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
       at WinStoreApp.Common.BindableBase.OnPropertyChanged(String propertyName)
       at WinStoreApp.Common.BindableBase.SetProperty[T](T& storage, T value, String propertyName)
       at WinStoreApp.DataModel.Model.StockItem.set_BidVol(String value)
       at WinStoreApp.Core.FIDValueMapper.PopulateFIDValue(Int32 fid, String value, StockItem stockItem)
       at WinStoreApp.Core.StockFeedReceiver.<ProcessData>d__20.MoveNext()

    Code snippet of message received:

     static async void _websocket_MessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)
                    using (var reader = args.GetDataReader())
                        reader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;
                        string message = reader.ReadString(reader.UnconsumedBufferLength);
                        await myObj.Message = message; // Exception here
                catch (Exception ex)


    Please let me know what may the problem.

    • Edited by Sandeep.mys Friday, January 2, 2015 8:26 AM Added more spaces between the code snippet
    Friday, January 2, 2015 8:26 AM


  • Hi,

    According to your description, I think you can received message from server by using MessageWebSocket class, but the data you received may not be right. I see the document in the link below:


    In the document above indicates:

    StreamSocket class is a stream socket to use for incoming or outgoing network communication over TCP

    MessageWebSocket is a message-based WebSocket.

    If the server send the data based on stream format, the MessageWebSocket class may not received the right data.

    You can use StreamWebSocket to see whether the problem occur. And you should give us more information and upload a test project to OneDrive so that we can test it.

    Best Wishes!

    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. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by Anne Jing Monday, January 12, 2015 7:59 AM
    Monday, January 5, 2015 9:56 AM