0

On a Universal App project I'm trying to deserialize a XML file, in the Windows version it works fine but in Windows Phone I ran into the following error:

{System.InvalidOperationException: global::App.Data.DataItem cannot be serialized because it does not have a parameterless constructor. at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderList1.Read2_DataItem (Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderList1.Read3_ArrayOfDataItem()}

How can I solve this? My code: [link]

cap7
  • 482
  • 5
  • 24
  • Maybe this will help, I wrote it awhile back: http://stackoverflow.com/questions/24788238/deleting-on-array-item-in-windows-phone-c-sharp-app-and-never-show-it-in-next-ap/24792062#24792062 – Chubosaurus Software Oct 09 '14 at 02:30
  • Serialization needs parameterless constructor, even if you don't use it. Try to add in `DataItem` class: `public DataItem() { UniqueID = string.Empty; Title = string.Empty; ... }` – Romasz Oct 09 '14 at 05:56
  • @celsoap if you could post the code for the deserialization? – Kulasangar Oct 09 '14 at 14:01
  • I have followed @Romasz suggestion and replaced my internal constructor for that one. Now it works perfectively on both plataforms. – cap7 Oct 09 '14 at 21:00

0 Answers0