Missing System.IO.Compression.Native.dll in .NET 8 leads to error when using GZipStream

63 views Asked by At

I have recently upgraded a .NET 6 application (ASP.NET Core MVC) to .NET 8. Testing the upgrade worked perfectly fine on my development machine. But when testing this on an external machine (which has .NET 8 SDK installed), a function that would extract data from zipped stream fails with the following:

var inputStream = new MemoryStream(gZippedFile);
FAILS --> var archive = new GZipStream(inputStream, CompressionMode.Decompress);

System.IO.Compression.ZLibException: The underlying compression routine could not be loaded correctly. ---> System.DllNotFoundException: Unable to load DLL 'System.IO.Compression.Native' or one of its dependencies: The specified module could not be found. (0x8007007E) at System.IO.Compression.ZLibNative.ZLibStreamHandle.InflateInit2_(Int32 windowBits) at System.IO.Compression.Inflater.InflateInit(Int32 windowBits) --- End of inner exception stack trace --- at System.IO.Compression.Inflater.InflateInit(Int32 windowBits) at System.IO.Compression.DeflateStream..ctor(Stream stream, CompressionMode mode, Boolean leaveOpen, Int32 windowBits, Int64 uncompressedSize) at System.IO.Compression.GZipStream..ctor(Stream stream, CompressionMode mode, Boolean leaveOpen) at [...]

I have observed that this "System.IO.Compression.Native" assembly was never directly referenced in any of the .NET 6 or .NET 8 deps.json file. In both, I can only find the same reference to System.IO.Compression assembly:

 "System.IO.Compression/4.3.0": {
    "dependencies": {
      "Microsoft.NETCore.Platforms": "1.1.0",
      "System.Buffers": "4.5.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": "4.3.0",
      "runtime.native.System.IO.Compression": "4.3.0"
    }
  },

Unfortunately, I have no control over the system that creates the compressed file.

I have a hunch that I am missing something completely obvious, but I cannot put my finger on it :-(

Any help is deeply appreciated!

0

There are 0 answers