![](/img/trans.png)
[英]'Could not load file or assembly System.IO.Compression' on UWP
[英]Can't find System.IO.Compression assembly
調用System.IO.Compression.Zipfile.CreateFromDirectory
,遇到以下錯誤:
但是,我的項目確實包含錯誤中提到的程序集的第一個版本(見下面的屏幕截圖)。
四處搜索后,我發現此錯誤可能是由於沒有該項目具有的System.IO.Compression.FileSystem
程序集而引起的:
我嘗試使用/刪除System.IO.Compression.Zipfile
程序集(我發現它只是System.IO.Compression.FileSystem
的“鏈接”),更改System.IO.Compression
版本,但沒有任何效果。
該項目在 .NET Framework 4.6.1 下運行。
有沒有人知道如何解決這個問題? 謝謝 !
您可以在應用程序的配置文件中手動添加以下綁定重定向:
<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>
改變這個
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.Compression.ZipFile.UseBackslash=true" />
</runtime>
到
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.Compression.ZipFile.UseBackslash=false" />
</runtime>
就我而言,我將以下內容添加到 web.config runtime/assemblyBinding 節點:
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.