ArgumentException when deserializing XML in Windows App (UWP)

400 views Asked by At

I am trying to deserialize a simple XML string to an object in a Windows App (UWP).

I get an ArgumentException with "Value cannot be null. Parameter name: format" from withing the serializer.Deserialize(reader); call.

I tried the same thing in a Console application and it works perfectly, so the XML must be valid/parsable. Here is my code:

public async Task<DeviceDescription> GetDeviceDescription()
    {
        var settings = new XmlReaderSettings();
        var obj = new DeviceDescription();
        var reader = XmlReader.Create(BaseUrl + "/" + DeviceDescriptionUrl, settings);
        var serializer = new System.Xml.Serialization.XmlSerializer(typeof(DeviceDescription));
        obj = (DeviceDescription)serializer.Deserialize(reader);

        return obj;
    }

This code is part of a Portable Library which I referenced from the Windows App and Console application. As mentioned before, deserializing works from the Console application but fails with the above error in the Windows App.

I am running my Windows App on Windows 10 from VS2015RC as well as on a Raspberry Pi 2 running Windows IoT core. Both show the same behavior.

So, why is this failing in my Windows App? Thank you

0

There are 0 answers