XmlSerializer Deserialize fails in release mode

juvestar

New Member
This is pretty odd. I have a configuration file which is well formed XML. I create a stream from the file and serialize it using what seems to be pretty typical code:\[code\]TextWriter tw = new StreamWriter(tempFile);\[/code\]I use a serializer created as follows:\[code\]XmlSerializer ConfigSettingSerializer = new XmlSerializer(typeof(ConfigSettings));\[/code\]Where ConfigSettings is just a container class containing string variables and values.I then take the serialized stream and stash it away as a configuration using the ConfigurationManager class and AppSettings. I then retrieve the serialized data from appSettings and attempt to convert the stream back to the original class:\[code\]string configXml = ConfigurationManager.AppSettings[Id];using (StringReader reader = new StringReader(configXml)) { retVal = (ConfigSettings)MVHelper.ConfigSettingSerializer.Deserialize(reader); } \[/code\]This all works perfectly well until I switch from Debug to Release, when I get an error on the Deserialize call about invalid XML, complaining about the very last character in the document: There is an error in XML document (92, 18). The inner exception is: "Data at the root level is invalid. Line 92, position 18". The document is identical to the one generated in debug mode, and it renders fine in any browser. My guess is that there maybe something else going on and that the real error is somehow being masked, but so far I don't see it. Any advice would be greatly appreciated.Thanks,Gary
 
Back
Top