c# - 找不到该组件。 (来自 HRESULT : 0x88982F50) 的异常

标签 c# stream windows-runtime windows-phone-8.1 storagefile

每当我尝试从本地文件检索图像时,上述异常发生在 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);
        }
    }

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

有什么帮助吗?

最佳答案

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

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

关于c# - 找不到该组件。 (来自 HRESULT : 0x88982F50) 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30273307/

相关文章:

c# - 通过CMD以兼容模式运行可执行文件

c# - 将 Xml 反序列化为对象时出错 - xmlns ='' 不是预期的

javascript - Node - 在管道之后正确关闭流

node.js - EOF 后出现错误 : stream. Push()

c# - WinRT 的 TcpListener 类在哪里?

c# - 移动/更新命名空间声明时如何阻止 ReSharper 删除未使用的 Using 语句?

c# - 使用 ODBC 连接在代码隐藏中加载 Crystal Report

node.js - 有没有一种方法可以使用 Node/Express 2.x 检查已发送的 header ?

c# - 如何在 WinRT 8.1 上 P/调用 kernel32.dll

winforms - Windows 8 密码框占位符