问题描述:

I have a XML-File which was serialized on the development server. As long as i deserialze the same file using the development setup everything works as expected.

But when trying to deserialize the same file on the production box, i only get empty strings.

No exceptions are thrown nor can i see why this is happening.

The deserialization works as follows:

XmlSerializer xmlSerializer = new XmlSerializer(typeof(XMLFile));

StreamReader xmlReader = new StreamReader(xmlFile);

try

{

retVal = (XMLFile)xmlSerializer.Deserialize(xmlReader);

xmlReader.Close();

}

catch (Exception exception)

{

ErrorHandler.Instance.LogException(exception);

}

finally

{

xmlReader.Dispose();

}

The xmlFile-Definition looks like this:

[XmlRoot("Config")]

public class Config

{

[XmlElement("Prop1")]

public string Prop1 { get; set; }

[XmlElement("Prop2")]

public string Prop2 { get; set; }

}

The serialized file looks loke this:

<?xml version="1.0" encoding="utf-8"?>

<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<Prop1>Test</Prop1>

<Prop2>Test</Prop2>

</Config>

相关阅读:
Top