는 다음 코드와 격리 된 저장소에서 개체를 읽고있다 :직렬화 된 객체를 읽는 중 오류가 발생 했습니까? WP7
public static T Load<T>(string name) where T : class, new()
{
T loadedObject = null;
using (IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication())
using (IsolatedStorageFileStream storageFileStream = new IsolatedStorageFileStream(name, System.IO.FileMode.OpenOrCreate, storageFile))
{
if (storageFileStream.Length > 0)
{
DataContractSerializer serializer = new DataContractSerializer(typeof(T));
loadedObject = serializer.ReadObject(storageFileStream) as T; //####Error Here####
}
if (loadedObject == null)
{
loadedObject = new T();
}
}
내 객체를 읽고되면 나는
"유형 'Microsoft.Xna.Framework.Media를 읽고 SecurityException를 얻고있다. Song은 매개 변수없는 public 생성자가 없기 때문에 부분 신뢰로 deserialize 할 수 없습니다. "
내 개체 클래스에 위와 같은 오류가 발생하는 Song 속성이 있습니다.
이 문제를 해결할 방법이 있습니까? 내 Song 속성을 내 개체와 함께 저장하고 싶습니다. 모든 조언을 크게 주시면 감사하겠습니다! 감사!
Song 속성이 포함 된 개체를 저장하고 있습니다. Isolated 저장소에서 개체를 읽을 때 Song 속성을 읽어야합니다. – andersra
내 현재 방법을 사용하여이 문제를 해결할 방법이 없다고 말씀 하시겠습니까? – andersra
노래를 저장하는 대신 (왜 내가 그렇게 할 수 없는지 깨닫습니다.) MediaLibrary에 색인을 저장했습니다. 노래. 이제 개체를로드하고 모든 노래 속성을 다시 설정할 수 있습니다. – andersra