簡體   English   中英

找不到 System.IO.Compression 程序集

[英]Can't find System.IO.Compression assembly

調用System.IO.Compression.Zipfile.CreateFromDirectory ,遇到以下錯誤:

System.IO.Compression 異常

但是,我的項目確實包含錯誤中提到的程序集的第一個版本(見下面的屏幕截圖)。

四處搜索后,我發現此錯誤可能是由於沒有該項目具有的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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM