在“System.IO.Compression"命名空间中找不到“ZipArchive" [英] Cannot find `ZipArchive` in the “System.IO.Compression” namespace

查看:43
本文介绍了在“System.IO.Compression"命名空间中找不到“ZipArchive"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与

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

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

我错过了什么?

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

<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"/></组件>

摘自 这个答案 到已安装 .Net 4.5 但不能在 Visual C# 中使用 ZipFile 类">

解决方案

您可以直接更新项目文件中的引用(卸载项目并编辑此文件或使用记事本打开 .csproj 文件并编辑)

之前编辑必须与:

<Reference Include="System.IO.Compression.FileSystem"/>

修改后:

<Reference Include="System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/><Reference Include="System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/>

在 Visual Studio 中再次加载您的项目并重建它.希望能帮到你.

My question is related to I didn't find "ZipFile" class in the "System.IO.Compression" namespace

But I have referenced the DLL's for my 4.5.1 webforms project:

Properties of my project give me: Target framework: .Net Framework 4.5.1. and the web.config:

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

What am I missing?

The solution was to manually reference the assemblies in the web.config But why? Why wasn't the checkbox in the add reference dialog insufficient?

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

Taken from this answer to "Installed .Net 4.5 but can't use ZipFile class in Visual C#"

解决方案

you can update References in Project file directly (Unload Project and Edit this or open .csproj file with notepad and edit)

Before edit must same as:

<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />

After your edit:

<Reference Include="System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
<Reference Include="System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />

load again your project in Visual Studio and rebuild it. I hope it can help you.

这篇关于在“System.IO.Compression"命名空间中找不到“ZipArchive"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆