When calling the System.IO.Compression.Zipfile.CreateFromDirectory
, I am met with the following error :
However, my project does contain the first version of the assembly mentioned in the error (seen in the screenshot below).
After searching around, I saw that this error could arise from not having the System.IO.Compression.FileSystem
assembly , which this project has :
I tried using / removing the System.IO.Compression.Zipfile
assembly (which I found out is just a "link" to System.IO.Compression.FileSystem
), changing System.IO.Compression
versions , but nothing worked.
This project runs under the .NET Framework 4.6.1.
Does anyone have an idea of how to troubleshoot this one ? Thanks !
You can manually add the following binding redirect in your application's config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression.ZipFile" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Change this
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.Compression.ZipFile.UseBackslash=true" />
</runtime>
To
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.Compression.ZipFile.UseBackslash=false" />
</runtime>
In my case I added the following to web.config runtime/assemblyBinding node:
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.