繁体   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