4

クラスのタイプであるオブジェクトのコレクションを保存しようとしています。次のようなエラーが表示されます。

コレクション データ コントラクト型 '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();
4

1 に答える 1

6

クラスを公開する

public class Lekarna

于 2013-08-06T08:14:26.873 に答える