Crashes Back (WriteableBitmap cannot be serialized) windows phone 8

和自甴很熟 提交于 2019-12-25 05:09:13

问题


When I choose to complete the first page photo Change to the second page of the selected photo will crashes Back

I have read this post

Crashes Back to AppPage from Home ('System.Windows.Media.ImageSource' cannot be serialized) WP8

but I don't know how to deleting BitmapSource Property

this is my code

PhotoChooserTask pc;
BitmapImage finalImage;

pc = new  PhotoChooserTask();
pc.Completed += new EventHandler<PhotoResult>(pc_co);


  public void pc_co(object sender, PhotoResult e)
    {


        if (e.TaskResult == TaskResult.OK)
        {

            finalImage = new BitmapImage();
            finalImage.SetSource(e.ChosenPhoto);
            img.Source = finalImage;

        }

    }

and Crashes Back message

exception  {System.Runtime.Serialization.InvalidDataContractException: Type 'System.Windows.Media.Imaging.WriteableBitmap' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.

来源:https://stackoverflow.com/questions/20094020/crashes-back-writeablebitmap-cannot-be-serialized-windows-phone-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!