C# Parsing JSON data within Mobile project OR via Controller Issue RRS feed

  • Question

  • When I invoke the following to a custom controller to return data to my client (Windows Phone 8.1 app):

    var _lines = await App.MobileService.InvokeApiAsync<List<Tfl.Api.Presentation.Entities.Line>>("lines", System.Net.Http.HttpMethod.Get, new Dictionary<string, string>
                    {"url", "http://api.tfl.gov.uk/Line"}

    I received the following Exception:-

    FileNotFoundException was caught 
    Could not load file or assembly 'System.Runtime.Serialization, 
    Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one 
    of its dependencies. The system cannot find the file specified.

    However, I successfully parse the JSON data via the controller [I did have an image here displaying the data, but not enough rep to post!] and I also have no references to the above dll in my Windows Phone application.

    Any ideas?

    Note: Occurs using either local parsing within the mobile app or via controllers in a service app; also running VS Ultimate 2013 with Update 4

    • Edited by davidcrossey Friday, March 27, 2015 11:59 PM Formatting
    Friday, March 27, 2015 11:58 PM

All replies

  • Hi davidcrossey,

    As I understand from your description, looks like the Windows Phone does give exception while the Serizlication object is passed here, but totally works fine on JSON data, is that correct?

    Base on the Exception I think you may also check what .net version of serialization, as I know Windows Phone 8.1 use .Net 4.5 but the assembly you are missing seems from 4.0, would you double check it? Or perhaps the service side is still using 4.0.


    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, March 30, 2015 1:46 AM
  • Hi James,

    The data is deserializing using System.Runtime.Serialization on the client side (which is targeting .NET 4.5). I am using a third party DLL found here (api.tfl.gov.uk) which contains all of the data transfer objects required to map the data from the JSON into an object structure.

    I have tested this DLL also within a console application and runs as expected, deserializing and mapping data etc; could the issue be that the DLL I'm using containing DataContract and DataMember annotations cannot be used as a reference within the Windows Phone 8.1 app?

    I say this because I have a solution whereby I 'copy' the DTO modes in the DLL into plain models using the same code (minus Serialization annotations) and the JSON then is able to deserialize and map to those in the phone.

    So the solution are present is to create my own models, however if you've any other ideas/workarounds that would be great to know in the future where I can just reference the third party DLL.

    Thanks for the response!


    Wednesday, April 1, 2015 3:51 PM