【问题标题】:The component cannot be found. (Exception from HRESULT: 0x88982F50)找不到该组件。 (来自 HRESULT 的异常:0x88982F50)
【发布时间】:2015-05-16 08:08:14
【问题描述】:

每当我尝试从本地文件中检索图像时,上述异常发生在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 错误通常与无法正确读取/解码图像文件有关。验证您的文件格式是否正确。 (谷歌 88982f50 可以看到几十个可能相关的修复程序,都与图像文件 I/O 相关。)这也是我的问题...错误文件。
  • @sraboy 谢谢,你为我节省了一天:) 0 字节大小或格式错误的错误文件。我们应该始终检查流是否成功创建
  • 在 Windows UWP 上使用 ImageLib 时也会出现此问题。如何检查流是否成功创建?我猜只是检查它是否不为空,并捕获潜在的异常。
  • @sraboy 很高兴成为第一个为您的答案投票的人。

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


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    迟到的答案,但可能会避免其他人花费数小时来寻找这个......

    错误代码 0x88982f50 是 WINCODEC_ERR_COMPONENTNOTFOUND,这是 Windows 映像组件表示它无法解码图像文件的方式。

    文件很可能已损坏,或者安装在 Windows 中的 WIC 版本不包含解码它所需的编解码器。

    微软提供零信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-23
      • 2015-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多