Cannot deserialize previously serialized XML with c# xmlserializer -


i have use externally given xml structure (huge). use xsd tool of visual studio generate classes should (de)serialized using xmlserializer. since switched vs2010 vs2012 (but still targeting .net 4.0), have problems deserializing xml. broke down following code:

using system.io; using system.xml; using system.xml.serialization;  using microsoft.visualstudio.testtools.unittesting;   /// <remarks/> [system.codedom.compiler.generatedcodeattribute("xsd", "4.0.30319.1")] [system.serializableattribute] [system.diagnostics.debuggerstepthroughattribute] [system.componentmodel.designercategoryattribute("code")] [xmlrootattribute("decoderparameter", namespace = "", isnullable = false)] public class decoderparametertype {     private string[] decoderupdatepointsfield;      /// <remarks/>     [xmlattributeattribute(datatype = "integer")]     public string[] decoderupdatepoints     {                 {             return this.decoderupdatepointsfield;         }         set         {             this.decoderupdatepointsfield = value;         }     } }  [testclass] public class unittest1 {     #region public methods , operators      [testmethod]     public void testmethod1()     {         var filename = "c:\\temp\\test.xml";          var deserializer = new xmlserializer(typeof(decoderparametertype));          var output = new decoderparametertype { decoderupdatepoints = new[] { "5", "7", "9" } };          using (var fs = new filestream(filename, filemode.create))         {             deserializer.serialize(fs, output);         }          using (var sr = new xmltextreader(filename))         {             var myparameter = (decoderparametertype)deserializer.deserialize(sr);         }     }      #endregion } 

this code snippet fails exception:

system.xml.xmlexception: 'none' invalid xmlnodetype.

it works if remove "datatype = integer" xmlattributeattribute.

now have following questions:

  • why installing .net4.5 change behaviour of .net4.0 - program? or not case , missing something? (before installed vs2012, worked fine! neither in vs2010 nor in vs2012 working)
  • what side effects has removal of datatype declaration?
  • which other datatype declarations affected? have lot of these declarations in generated code, not integer (nonnegativeinteger, date, etc...).

update: problem occurs if variable array.

kind regards

well, first bullet easy one:

  • why installing .net4.5 change behaviour of .net4.0 - program?

because .net 4.5 over-the-top install, not side-by-side install. when install .net 4.5 changing 4.0 assemblies. act of targeting 4.0 vs 4.5 determines whether ide let reference 4.5 specific features. when targeting 4.0, once install 4.5 using 4.5 implementation code-changes (bug-fixes, changed behaviors, , new bugs) associated 4.5.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -