c# - Deserialization of properties won't work, but works in TestProject and Generic-Lists -
I have an application that is a rally funny problem with deserialization of my application settings-class. The square resembles the following:
[serialable] public class ApplicationSettings {public string selected settings {get; Set; } Public string selected settings {get; Set; } Public string selectedDatabase setting {get; Set; } Public string selected computing setting {get; Set; } Public listing & lt; General Settings & gt; General Settings = New List & lt; General Settings & gt; (); Public listing & lt; Checking & gt; CheckSettings = New list & lt; Checksetting & gt; (); Public listing & lt; DataBaseSetting & gt; Database Settings = New List & lt; Database Settings & gt; (); Public listing & lt; Compare & gt; Compare = new list & lt; Compare & gt; (); Public application settings () {}} The serialization of this class works fine, but deserialization will not work, the general settings selected in the public properties, the selected settings, selected data setting, and select contact settings are zero. I am deserializing this method using: Private zero deserialize () {XmlSerializer serializer = New XmlSerializer (typeof (ApplicationSettings)); Filestream file = new filestream (application settingspath + @ "\ settings.xml", flammed.open); ApplicationSettings = (serializer.Deserialize (file) as ApplicationSettings); File.Close (); } Two strange things, there are many properties in the lists and they are properly degraded. I created a test-project, in which a public member and property and a general list It was, all was successfully deserialized. I do not really have any idea why it should not work in the "main project" is anyone's advice? How deserialization can behave so weird? Hello!
This code works for me.
Private Zero form1_load (object sender, eventArgse E) {XML serializer serializer = new XML Scribus (typef (application settings)); XmlReader Reader = XmlReader.Create (New String Reader (@ "Lt. XML version =" "1.0" "?? Gt; & lt; Application Settings & gt; & lt; General General Settings & gt; Default & Lt; / General selected General General & gt; General Settings & gt; & lt; General Settings & gt; & lt; Name & gt; DDD & lt; / Name & gt; & lt; / General Settings & gt; & lt; / General Settings & gt; & lt; / ApplicationSettings & gt; ")); Var result = (Serializer.Deserialize (Reader) as ApplicationSettings); } [Serialable] public class application settings {public string selected settings {get; Set; } Public listing & lt; General Settings & gt; General Settings = New List & lt; General Settings & gt; (); } Public class generalising {public string name {get; Set; }}
Check [BR] text in your sample text
Comments
Post a Comment