Json Deserialization not working after app publish in store RRS feed

  • Question

  • Hi,

    I have a very annoying problem with my app. I'm using Json.net to deserialize json content. When I'm testing my app on emulator or device connected through Visual Studio everything works fine and data is deserializing. But after I build package to publish in the store the deserialization is not working and I'm catching NullReferenceException in line:

    return (TItem)serializer.Deserialize(streamReader, typeof(TItem));

    of code:

    protected TItem DeserializeJson<TItem>(String json)
                if (json != null)
                        using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json)))
                            JsonSerializer serializer = new JsonSerializer();
                            using (StreamReader streamReader = new StreamReader(ms))
                                return (TItem)serializer.Deserialize(streamReader, typeof(TItem));
                    catch (Exception ex)
                return default(TItem);

    I was also using DataContractJsonSerializer with the same exception...

    It's very strange because when I prepare package with the No answer on the first page of Create App Packages and then I deploy this package on my phone through Window Phone Application Deployment the data deserialization is working perfectly.

    I really don't have any idea why it's not working... It really drives me crazy :/

    Maybe someone from Microsoft could help me with that problem?

    I'm using Visual Studio 2013 Update 4. My app is built as a Windows Phone 8.1 app.


    Monday, April 20, 2015 8:48 PM

All replies

  • Let me recommend this - build a debug version with lots of logging in it and upload to the beta store for testing. It's not an optimal situation, but I think it would help here.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, April 22, 2015 12:35 PM
  • Well I have done this. As I said in debug package everything is working fine. But after I prepare the package for store deserialize method is throwing NullReferenceException. The problem happens after I have added Application Insight to my app. But it didn't disappear after I remove the references. I'm afraid that Application Insight changed something in my project structure that is why I'm getting such error.
    Thursday, April 23, 2015 8:04 AM
  • Ok, I'm a one step closer to the problem. While creating App Package when I check the option to prepare App Bundle and then when I install it to my device with Windows Phone Application Deployment the json deserialization is working fine. But after I publish my app to the store with the same app package, deserialization is throwing NullReferenceException. I don't know what publish and certification process is doing with my package, but after this my app is unusable.

    Is there someone who can help me with this problem?

    Thursday, April 23, 2015 7:50 PM