Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
713 views
in Technique[技术] by (71.8m points)

c# - Unzipping throws an "The underlying compression routine could not be loaded correctly"

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())
  {

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

with the inner exception

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

Important to note:

  • 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

using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create,true))

  • I am using Xamarin forms (I don't think this is relevant)

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).

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I found the root cause. As Jay Zuo said, the problem is that in the project.lock.json is somehow referencing the "System.IO.Compression 4.3.0".

I am not directly referencing it in any project.json file. I am indirectly referencing it by a .NETSTANDARD1.1 project with a reference to the "NETStandard.Library": "1.6.1".

By using nuget.org I searched for a "NETStandard.Library" version using the older System.IO.Compression 4.1.1, which is "NETStandard.Library" 1.6.0.

Using the "NETStandard.Library" 1.6.0. in the .NETSTANDARD 1.1 project fixed the unzip error.

I uploaded a sample solution to reproduce the error. https://1drv.ms/f/s!AqROiejT4oI3lMMc_jWogCQy36awrA


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...