找不到该组件.(来自HRESULT的异常:0x88982F50)

Moh*_*jNK 9 c# stream windows-runtime storagefile windows-phone-8.1

await bitmapImage.SetSourceAsync(fileStream);每当我尝试从本地文件中检索图像时,就会出现上述异常.

这是我用于存储和检索图像文件的方法.

    public async Task<BitmapImage> RetrieveImageFromFile(String fileName)
    {
        try
        {
            StorageFile localFile = await _storageFolder.GetFileAsync(fileName + "Img");
            BitmapImage bitmapImage = new BitmapImage();
            using (IRandomAccessStream fileStream = await localFile.OpenAsync(FileAccessMode.Read))
            {
                await bitmapImage.SetSourceAsync(fileStream);
            }
            return bitmapImage;
        }
        catch(Exception e)
        {
            return null;
        }
    }

    public async void WriteImageToFile(string fileName, IRandomAccessStreamWithContentType stream )
    {
        StorageFile file = await _storageFolder.CreateFileAsync(fileName + "Img", CreationCollisionOption.ReplaceExisting);
        Stream streamToSave = stream.AsStreamForWrite();
        using (Stream fileStram = await file.OpenStreamForWriteAsync())
        {
            streamToSave.CopyTo(fileStram);
        }
    }
Run Code Online (Sandbox Code Playgroud)

从contact.Thumbnail.OpenReadAsync()方法检索WriteImageToFile方法的输入流.

有帮助吗?

sra*_*boy 6

只是将我的评论变成答案,因为它一直在帮助人们:

0x88982f50错误通常与无法正确读取/解码图像文件有关。验证您的文件格式是否正确。Google 88982f50 查看数十个可能相关的修复程序,所有这些修复程序都与图像文件 I/O 有关。我从未找到错误的明确来源,但这也是我的问题......文件错误。