开发者

c# Stream.Seek is giving me a 'NullReferenceException'

开发者 https://www.devze.com 2023-04-05 01:11 出处:网络
I\'m losing my mind over this one.Can anyone spot an error in my code following this comment as it is giving me a NullReferenceException error at the point highlighted....Thanks in advance for any sug

I'm losing my mind over this one. Can anyone spot an error in my code following this comment as it is giving me a NullReferenceException error at the point highlighted.... Thanks in advance for any suggestions...

    //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);
    Ap开发者_开发知识库p._capturedImage.SetSource(file); <------  THROWS ERROR HERE, suggest file  = NullReferenceException ???????????????????

    //Get rid of the stream....
    file.Dispose();


A shot in the dark: probably _capturedImage is the null one.


Either _capturedImage is the null reference, or (supposing App is a field or property rather than a class name) App is returning the null reference.

0

精彩评论

暂无评论...
验证码 换一张
取 消