c# - 在 `ZipArchive` 命名空间中找不到 “System.IO.Compression”

标签 c# reference .net-4.5 assemblies

我的问题与 I didn't find "ZipFile" class in the "System.IO.Compression" namespace 有关

The type or namespace name 'ZipArchive' does not exist in the namespace 'System.IO.Compression'

但我已经为我的 4.5.1 webforms 项目引用了 DLL:

Screenshot of 'References' tab

我项目的属性给我:目标框架:.Net Framework 4.5.1。 和 web.config:

<compilation debug="true" targetFramework="4.5" />

我错过了什么?

解决方案是手动引用 web.config 中的程序集但是为什么呢?为什么添加引用对话框中的复选框不够用?

<assemblies>
    <add assembly="System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>

取自this answer到“已安装 .Net 4.5 但不能在 Visual C# 中使用 ZipFile 类”

最佳答案

我遇到了同样的问题,因为引用中不存在命名空间,请执行以下步骤。

在我没有引用的情况下

When References not installed

安装引用后

enter image description here 解决方案

1)在此处从 nuget 安装 system.Io.compression

System.IO.Compression

2) 从此处的 nuget 安装 system.Install-Package 40-System.IO.Compression.FileSystem。

System.IO.Compression.FileSystem

关于c# - 在 `ZipArchive` 命名空间中找不到 “System.IO.Compression”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33802239/

相关文章:

c# - 如何使用带有格式的打开 xml 将 docx 转换为 html 文件

c# - 覆盖 Picturbox OnPaint 事件以旋转图像 - 创建自定义 Picturebox

c# - 如何在 MVC 中的 @Html.ActionLink 中获取更新的文本框更改值

c# - 错误 : Unable to load DLL '.dll' : The specified module could not be found.(HRESULT : 0x8007007E) - What is this error? 异常

c# - 如何将 async/await 与使用基于事件的异步模式的库一起使用?

c# - 如果使用命名空间版本路由,如何在 ASP.Net Core API 中设置 RESTful 属性路由

visual-studio - 在 VS 2012 Premium 中删除未使用的 Using

c# - 时间:2019-03-08 标签:c++c#equivaltentobjectinstance

c# - 从 C++ COM dll 生成的互操作程序集给出构建引用错误