解压缩将引发“无法正确加载基础压缩例程”。 [英] Unzipping throws an "The underlying compression routine could not be loaded correctly"

查看:409
本文介绍了解压缩将引发“无法正确加载基础压缩例程”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用以下代码在Win10移动版(UWP)上解压缩文件

Trying to unzip a file on Win10 mobile (UWP) with the following code

using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Read))
{
  ZipArchiveEntry entry = archive.Entries.First();
  using (Stream reader = entry.Open())
  {

在entry.Open()时出现以下错误。
基础压缩例程无法正确加载。

throws at entry.Open() the following error. "The underlying compression routine could not be loaded correctly."

有内部异常

无法加载DLL'clrcompression.dll':指定的模块无法加载(来自HRESULT的异常:0x8007007E)

"Unable to load DLL 'clrcompression.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

重要说明:


  • entry.Open()在Win10桌面上正常运行,但在具有相同项目(UWP)的Win10移动版上无法正常运行

  • 使用Win10移动版10.0.14393.576。 (Lumia 650)

  • 该项目的UWP目标版本为10.0 BUILD 14393

  • 为台式机和移动版使用相同的文件。

  • 使用简单的

  • The entry.Open() works fine on win10 Desktop but not on Win10 mobile with the same project (UWP)
  • Using Win10 mobile version 10.0.14393.576. (Lumia 650)
  • UWP target version of the project is 10.0 BUILD 14393
  • Using the same file for the Desktop and mobile version.
  • The file is created at the backend with a simple

在后端创建文件使用(ZipArchive存档= new ZipArchive(stream,ZipArchiveMode.Create,true))


  • 我正在使用Xamarin表格(我认为这不相关)

问题:
是否有人遇到过相同的例外情况?根本原因是什么?
有哪些可用的解决方法? (我需要跨平台压缩文件)

Questions: Has somebody experienced the same exception? What is the root cause of it? What are available workarounds? (I need the file compressed cross platform)

更新:我根据要求创建了一个简单的测试项目(感谢您对其进行研究)。

UPDATE: I created simple test project as requested (thanks for looking into it).

解压缩在测试项目中有效,但它正在加载其他模块。
调试/模块窗口指出,引发异常的项目使用System.IO.Compression.dll 4.06.24705.1,工作项目使用1.00.24301.1。

The unzip works in the test project, but it is loading a different module. The Debug/Modules window states that the exception throwing project uses System.IO.Compression.dll 4.06.24705.1, the working project uses 1.00.24301.1.

我上载了两个project.lock.json文件进行比较 https://1drv.ms/f/s!AqROiejT4oI3lL1q1tu3iJcfA2tKyg

I uploaded both project.lock.json files for comparison https://1drv.ms/f/s!AqROiejT4oI3lL1q1tu3iJcfA2tKyg.

推荐答案

根据项目.lock.json,我认为这里的问题可能与 System.IO.Compression 4.3.0程序包

According to the "project.lock.json" you've uploaded, I think the problem here may be related to the System.IO.Compression 4.3.0 package.

在抛出异常的项目中,您可以找到使用 System.IO.Compression 4.3.0 ,例如:

In the exception throwing project, you can find it uses "System.IO.Compression 4.3.0" like following:

"runtime.native.System.IO.Compression/4.3.0": {
  "type": "package",
  "dependencies": {
    "Microsoft.NETCore.Platforms": "1.1.0",
    "Microsoft.NETCore.Targets": "1.1.0"
  },
  "compile": {
    "lib/netstandard1.0/_._": {}
  },
  "runtime": {
    "lib/netstandard1.0/_._": {}
  }
},
...
"System.IO.Compression/4.3.0": {
  "type": "package",
  "dependencies": {
    "System.Buffers": "4.3.0",
    "System.Collections": "4.3.0",
    "System.Diagnostics.Debug": "4.3.0",
    "System.IO": "4.3.0",
    "System.Resources.ResourceManager": "4.3.0",
    "System.Runtime": "4.3.0",
    "System.Runtime.Extensions": "4.3.0",
    "System.Runtime.Handles": "4.3.0",
    "System.Runtime.InteropServices": "4.3.0",
    "System.Text.Encoding": "4.3.0",
    "System.Threading": "4.3.0",
    "System.Threading.Tasks": "4.3.0",
    "runtime.native.System.IO.Compression": "4.3.0"
  },
  ...

在工作项目中,它使用 System.IO.Compression 4.1.1:

And in the working project, it uses "System.IO.Compression 4.1.1":

"runtime.native.System.IO.Compression/4.1.0": {
  "type": "package",
  "dependencies": {
    "Microsoft.NETCore.Platforms": "1.0.1",
    "Microsoft.NETCore.Targets": "1.0.1"
  },
  "compile": {
    "lib/netstandard1.0/_._": {}
  },
  "runtime": {
    "lib/netstandard1.0/_._": {}
  }
},
...
"System.IO.Compression/4.1.1": {
  "type": "package",
  "dependencies": {
    "System.Collections": "4.0.11",
    "System.Diagnostics.Debug": "4.0.11",
    "System.IO": "4.1.0",
    "System.Resources.ResourceManager": "4.0.1",
    "System.Runtime": "4.1.0",
    "System.Runtime.Extensions": "4.1.0",
    "System.Runtime.Handles": "4.0.1",
    "System.Runtime.InteropServices": "4.1.0",
    "System.Text.Encoding": "4.0.11",
    "System.Threading": "4.0.11",
    "System.Threading.Tasks": "4.0.11",
    "runtime.native.System.IO.Compression": "4.1.0"
  },
  ...

似乎 System.IO.Compression 4.3.0程序包不能用于UW现在是P项目。当前,最新的稳定版本的 Microsoft.NETCore.UniversalWindowsPlatform包使用 System.IO.Compression 4.1.1包。通过添加 System.IO,您应该能够在工作项目中重现您的问题。压缩4.3.0程序包,如下所示:

It seems that System.IO.Compression 4.3.0 package can't be used in UWP project for now. Currently the latest stable version of "Microsoft.NETCore.UniversalWindowsPlatform" package uses "System.IO.Compression 4.1.1" package. And you should be able to reproduce your issue with the working project by adding System.IO.Compression 4.3.0 package in it like following:

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
    "System.IO.Compression": "4.3.0"
  },
  "frameworks": {
    "uap10.0": { }
  },
  "runtimes": {
    "win10-arm": { },
    "win10-arm-aot": { },
    "win10-x86": { },
    "win10-x86-aot": { },
    "win10-x64": { },
    "win10-x64-aot": { }
  }
}

所以要解决此问题,建议您检查项目的引用,并确保没有 System.IO.Compression 4.3.0包。如果确实需要使用 System.IO.Compression包,则可以尝试将其降级为 4.1.1。

So to fix this issue, I'd suggest you check the reference of your project and make sure there is no "System.IO.Compression 4.3.0" package. If you do need to use "System.IO.Compression" package, you can try to downgrade it to "4.1.1".

这篇关于解压缩将引发“无法正确加载基础压缩例程”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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