0
當我添加類型的BitmapImage我的班級我Windows 8的應用程序(如下圖),我得到的成員「vehicleImage」:無法序列類型「Windows.UI.Xaml.Media.Imaging.BitmapImage」
Cannot serialize member vehicleImage' of type 'Windows.UI.Xaml.Media.Imaging.BitmapImage', see inner exception for more details.
內部異常詳細信息:
System.Runtime.InteropServices.WindowsRuntime.RuntimeClass is inaccessible due to its protection level. Only public types can be processed.
代碼:
public BitmapImage vehicleImage
{
get
{
return m_vehicleImage;
}
set
{
Uri _baseUri = new Uri("ms-appx:///");
BitmapImage imageBitmap = new BitmapImage(new Uri(_baseUri, ImagePath));
m_vehicleImage = imageBitmap;
OnPropertyChanged("vehicleImage");
}
}
private async void SetImage()
{
var file = await Windows.Storage.KnownFolders.PicturesLibrary.GetFileAsync(ImagePath);
var fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
var img = new BitmapImage();
img.SetSource(fileStream);
vehicleImage = img;
}
我賽瑞亞將對象轉換爲XML。當我刪除這一點的代碼一切正常。我希望能夠擁有用戶從計算機中選擇的圖像(這就是爲什麼我要使用BitmapImage類型)。
任何幫助表示讚賞。
今晚我會嘗試。我甚至沒有想到XMLIgnore標籤。我希望它能起作用! – webdad3