Windows phone 8 无法序列化Windows Phone 8 ImageSource共享图像时出错

Windows phone 8 无法序列化Windows Phone 8 ImageSource共享图像时出错,windows-phone-8,Windows Phone 8,我正在尝试分享一个图像。我得到了一个图片对象,正在从中获取路径。调用ShareMediaTask时,它会抛出以下错误: 无法序列化System.Windows.Media.ImageSource 我仍然可以共享图像,但从共享返回时应用程序崩溃 这是我的密码: PictureModel picture = Singleton.Instance.BearPicture.Model.Images.Where(PictureModel => PictureModel.Bmp.Uri

我正在尝试分享一个图像。我得到了一个图片对象,正在从中获取路径。调用ShareMediaTask时,它会抛出以下错误:

无法序列化System.Windows.Media.ImageSource

我仍然可以共享图像,但从共享返回时应用程序崩溃

这是我的密码:

        PictureModel picture = Singleton.Instance.BearPicture.Model.Images.Where(PictureModel => PictureModel.Bmp.UriSource == (Image_View.Source as BitmapImage).UriSource).FirstOrDefault();


        var task = new ShareMediaTask();


        task.FilePath = picture.Picture.GetPath();

        task.Show();
我的PictureModel如下所示:

 public class PictureModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private string _uri;
    public string Uri
    {
        get { return _uri; }
        set
        {
            if (value != _uri)
            {
                _uri = value;
                NotifyPropertyChanged("Uri");
            }
        }
    }

    private string _relativePath;
    public string RelativePath
    {
        get { return _relativePath; }
        set
        {
            if (_relativePath != value)
            {
                _relativePath = value;
                NotifyPropertyChanged("RelativePath");
            }
        }
    }

    private BitmapImage _bmp;
    public BitmapImage Bmp
    {
        get { return _bmp; }
        set
        {
            if (value != _bmp)
            {
                _bmp = value;
                NotifyPropertyChanged("Bmp");
            }
        }
    }

    private Picture _picture;
    public Picture Picture
    {
        get { return _picture; }
        set
        {
            if (value != _picture)
            {
                _picture = value;
                NotifyPropertyChanged("Picture");
            }
        }
    }

    private void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

    }

}
  myFileStream = myStore.OpenFile(fileName, FileMode.Open, FileAccess.Read);
            MediaLibrary library = new MediaLibrary();
            Picture pic = library.SavePicture(fileName, myFileStream);
这个错误是从哪里来的?我只得到我的图像对象的来源,但我没有用它做任何其他事情。我的图片也保存在媒体库中,如下所示:

 public class PictureModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    private string _uri;
    public string Uri
    {
        get { return _uri; }
        set
        {
            if (value != _uri)
            {
                _uri = value;
                NotifyPropertyChanged("Uri");
            }
        }
    }

    private string _relativePath;
    public string RelativePath
    {
        get { return _relativePath; }
        set
        {
            if (_relativePath != value)
            {
                _relativePath = value;
                NotifyPropertyChanged("RelativePath");
            }
        }
    }

    private BitmapImage _bmp;
    public BitmapImage Bmp
    {
        get { return _bmp; }
        set
        {
            if (value != _bmp)
            {
                _bmp = value;
                NotifyPropertyChanged("Bmp");
            }
        }
    }

    private Picture _picture;
    public Picture Picture
    {
        get { return _picture; }
        set
        {
            if (value != _picture)
            {
                _picture = value;
                NotifyPropertyChanged("Picture");
            }
        }
    }

    private void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

    }

}
  myFileStream = myStore.OpenFile(fileName, FileMode.Open, FileAccess.Read);
            MediaLibrary library = new MediaLibrary();
            Picture pic = library.SavePicture(fileName, myFileStream);
在Appstart上,我搜索我的savedpicture文件夹,以获取图片对象,然后将其保存在我的PictureModel中

感谢您的帮助。 提前谢谢。 robidd

这可能有帮助:。请参阅KooKiz的评论

“相同的症状,相同的原因。您在某个时间点以电话状态存储了一个图像源(可能是PhoneApplicationService.Current.state或IsolatedStorageSettings.ApplicationSettings)。您必须找到位置!”

显然,我们可以间接导致这种错误。我有一个类似的问题,我找到了答案,也找到了你自己的问题

希望能有帮助。 干杯