2013-08-06 103 views
4

我正在嘗試保存作爲我的類的一種類型的對象的集合。我收到一個錯誤消息:Windows Phone 8 - 將列表保存到IsolatedStorage

集合數據合同類型System.Collections.Generic.List無法反序列化,因爲它沒有公共無參數構造函數。 添加公共無參數構造函數將修復此錯誤。

這裏是我的類:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
namespace MojProjekt 
{ 
    class Lekarna 
    { 
     public string Ime { get; set; } 

     public Lekarna() 
     { 
     } 
    } 
} 

這裏是我如何保存到IsolatedStorage:

List<Lekarna> lekarneList = new List<Lekarna>(); 
// here I then fill the list ... 
IsolatedStorageSettings localStorage = IsolatedStorageSettings.ApplicationSettings; 
localStorage.Add("lekarneList", lekarneList; 
localStorage.Save(); 
+0

當我嘗試像你已經完成的那樣在孤立存儲中保存列表,我明白了System.ArgumentException –

回答

6

使類公共

public class Lekarna

+1

和當然的屬性:) –

相關問題