c#流.Seek给了我一个'NullReferenceException'

本文关键字:一个 NullReferenceException Seek | 更新日期: 2023-09-27 18:08:39

我都快疯了。有没有人能在我的代码中发现一个错误,因为它给了我一个NullReferenceException错误在点突出显示....提前感谢任何建议…

    //retreive the picture from isolated storage
    Stream file = PicturesLoader.LoadFileFromStorage(PhoneApplicationService.Current.State[PictureCrop.PictureStateKey_Url].ToString());
    BitmapImage bi = new BitmapImage();
    bi.SetSource(file);
    //load _pic
    Picture _pic = new Picture();
    _pic.Name = "TempFile";
    _pic.Url = PhoneApplicationService.Current.State[PictureCrop.PictureStateKey_Url].ToString();
    _pic.Height = bi.PixelHeight;
    _pic.Width = bi.PixelWidth;
    _pic.Bitmap = bi;
    //save the new cropped image for later use
    file.Seek(0, SeekOrigin.Begin);
    App._capturedImage.SetSource(file); <------  THROWS ERROR HERE, suggest file  = NullReferenceException ???????????????????
    //Get rid of the stream....
    file.Dispose();

c#流.Seek给了我一个'NullReferenceException'

瞎猜:_capturedImage可能是null

要么_capturedImage是空引用,要么(假设App是一个字段或属性而不是类名)App返回空引用

相关文章: