You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using SharpCompress 0.28.1 in a .NET 4.6.2 unit test project I get the following exception:
System.IO.FileLoadException: Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at SharpCompress.Utility.Skip(Stream source)
at SharpCompress.Common.EntryStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
at SharpCompress.Readers.AbstractReader`2.Write(Stream writeStream)
at SharpCompress.Readers.AbstractReader`2.WriteEntryTo(Stream writableStream)
at SharpCompress.Readers.IReaderExtensions.<>c__DisplayClass4_0.<WriteEntryToFile>b__0(String x, FileMode fm)
at SharpCompress.Common.ExtractionMethods.WriteEntryToFile(IEntry entry, String destinationFileName, ExtractionOptions options, Action`2 openAndWrite)
at SharpCompress.Readers.IReaderExtensions.WriteEntryToFile(IReader reader, String destinationFileName, ExtractionOptions options)
at SharpCompress.Common.ExtractionMethods.WriteEntryToDirectory(IEntry entry, String destinationDirectory, ExtractionOptions options, Action`2 write)
at SharpCompress.Readers.IReaderExtensions.WriteEntryToDirectory(IReader reader, String destinationDirectory, ExtractionOptions options)
at ...
Analysis
Build output
The detailed MSBuild output of building the test project shows:
2> Unified primary reference "System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
2> Using this version instead of original version "4.0.2.0" in "C:\Users\xxx\.nuget\packages\sharpcompress\0.28.1\lib\netstandard2.0\SharpCompress.dll" because AutoUnify is 'true'.
2> Resolved file path is "C:\Users\xxx\.nuget\packages\system.buffers\4.5.1\ref\net45\System.Buffers.dll".
2> Reference found at search path location "{RawFileName}".
2> Found related file "C:\Users\xxx\.nuget\packages\system.buffers\4.5.1\ref\net45\System.Buffers.xml".
2> This reference is not "CopyLocal" because at least one source item had "Private" set to "false" and no source items had "Private" set to "true".
2> The ImageRuntimeVersion for this reference is "v4.0.30319".
Dependency of SharpCompress 0.28.1 (.NET Standard 2.0) assembly
Disassembling the SharpCompress 0.28.1 assembly with ildasm shows that it indeed references "System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51":
The SharpCompress 0.28.1 NuGet package depends on System.Buffers in the following way:
SharpCompress 0.28.1 → >= System.Memory 4.5.4 → >= System.Buffers 4.5.1
Signature of System.Buffers 4.4.0
Disassembling System.Buffers 4.4.0 NuGet package with ildasm, we get the following signature:
.assembly System.Buffers
{
// snip
.ver 4:0:2:0
}
Signature of System.Buffers 4.5.1
Disassembling System.Buffers 4.5.1 NuGet package with ildasm, we get the following signature:
.assembly System.Buffers
{
// snip
.ver 4:0:3:0
}
Conclusion
The .NET Standard 2.0 assembly of SharpCompress.dll which is contained in the SharpCompress 0.28.1 NuGet package depends on System.Buffers.dll which is contained in the System.Buffers 4.4.0 NuGet package (assembly version 4.0.2.0).
This creates a version conflict because the SharpCompress 0.28.1 NuGet package transitively depends on the System.Buffers 4.5.1 NuGet package (assembly version 4.0.3.0).
Workaround
I was able to work around this issue by forcing the System.Buffers NuGet version to 4.4.0:
The drawback is that it generates the following warning:
NU1605: Detected package downgrade: System.Buffers from 4.5.1 to 4.4.0. Reference the package directly from the project to select a different version.
MyProject.UnitTests -> SharpCompress 0.28.1 -> System.Memory 4.5.4 -> System.Buffers (>= 4.5.1)
MyProject.UnitTests -> System.Buffers (= 4.4.0)
The text was updated successfully, but these errors were encountered:
Bug description
Using SharpCompress 0.28.1 in a .NET 4.6.2 unit test project I get the following exception:
Analysis
Build output
The detailed MSBuild output of building the test project shows:
Dependency of SharpCompress 0.28.1 (.NET Standard 2.0) assembly
Disassembling the SharpCompress 0.28.1 assembly with ildasm shows that it indeed references
"System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"
:Dependency of SharpCompress 0.28.1 NuGet package
The SharpCompress 0.28.1 NuGet package depends on System.Buffers in the following way:
SharpCompress 0.28.1 → >= System.Memory 4.5.4 → >= System.Buffers 4.5.1
Signature of System.Buffers 4.4.0
Disassembling System.Buffers 4.4.0 NuGet package with ildasm, we get the following signature:
Signature of System.Buffers 4.5.1
Disassembling System.Buffers 4.5.1 NuGet package with ildasm, we get the following signature:
Conclusion
The .NET Standard 2.0 assembly of
SharpCompress.dll
which is contained in the SharpCompress 0.28.1 NuGet package depends onSystem.Buffers.dll
which is contained in the System.Buffers 4.4.0 NuGet package (assembly version 4.0.2.0).This creates a version conflict because the SharpCompress 0.28.1 NuGet package transitively depends on the System.Buffers 4.5.1 NuGet package (assembly version 4.0.3.0).
Workaround
I was able to work around this issue by forcing the System.Buffers NuGet version to 4.4.0:
The drawback is that it generates the following warning:
The text was updated successfully, but these errors were encountered: