System.IO.Compression compatability issues
Hi,
I have a project, using 4.6.1 with the new project format, which creates nuget packages (the idea being we will eventually change to target .NETStandard 2.0).
I have another project, which is using 4.6.1 with the traditional xml project format, which consumes that package. This project uses System.IO.Compression.ZipFile to extract the contents of uploaded zips. This is where the problems start to happen though;
-
On my development machine, where I have installed the .NET 2.0 SDKS, I have to do an assembly redirect of version 4.1.2.0 of System.IO.Compression to 4.2.0.0. This seems to resolve the problems for me. However, on other machines, where the SDK is not installed, but the 461 runtime is installed, this fails with
System.IO.FileLoadException: Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its depend encies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) -
If I do not do the redirect (and in fact, just redirect down to 4.1.2.0), it works on the other machines, but fails for me with
Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I should point out that prior to importing the 461 package, the code was using 4.1.2.0 happily.
If it helps, here is the project file for the package - you'll note there is no reference to System.IO.Compression or System.IO.Compression.FileSystem;
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<OutputType>Library</OutputType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.IdentityManagement" Version="3.3.5.3" />
<PackageReference Include="AWSSDK.S3" Version="3.3.12.1" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.4.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Security.Cryptography">
<HintPath>..\packages\Security.Cryptography.1.7.2\lib\net35\Security.Cryptography.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Caching" />
</ItemGroup>
</Project>
My worry is that I can only seem to fix this by installing the SDK - which is not something I'd anticipate doing on our production systems.
Hi - any suggestions for a work around for this?