找不到该组件.(来自 HRESULT 的异常:0x88982F50) [英] The component cannot be found. (Exception from HRESULT: 0x88982F50)

查看:50
本文介绍了找不到该组件.(来自 HRESULT 的异常:0x88982F50)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试从本地文件中检索图像时,都会在 await bitmapImage.SetSourceAsync(fileStream); 行发生上述异常.

The above exception occurs at line await bitmapImage.SetSourceAsync(fileStream); whenever I tried to retrieve image from local file.

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

This is the method I'm using for storing and retrieving the image file.

    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);
        }
    }

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

The input stream for the WriteImageToFile method is retrieved from contact.Thumbnail.OpenReadAsync() method

有什么帮助吗?

推荐答案

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

Just turning my comment into an answer since it's been helping people:

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

The 0x88982f50 error is generally related to a failure to read/decode an image file correctly. Verify your file is formatted properly. Google 88982f50 to see dozens of potentially related fixes, all relating to image file I/O. I never did find a definitive source for the error but this turned out to be my problem as well... Bad file.

这篇关于找不到该组件.(来自 HRESULT 的异常:0x88982F50)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆