我對這個失去了我的想法。任何人都可以發現錯誤在我的代碼註釋,因爲是給我一個NullReferenceException錯誤在強調一點....在此先感謝您的任何建議以下...c#Stream.Seek給我一個'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();
難道你不能把一個斷點,而不是猜測? App,_capturedImage也可以爲null。 – Polyfun
在這段代碼中,App和_apturedImage都從天而降。優秀的NRE候選人。 *文件*變量不是。使用調試器。 –
我會推薦這個[在C#中調試指南](http://msdn.microsoft.com/en-us/vcsharp/aa336801)。也許在C#的基礎課程之上。 –