【问题标题】:Azure Function App - referencing external libraryAzure Function App - 引用外部库
【发布时间】:2018-10-30 17:54:00
【问题描述】:

我在用 C# 脚本编写的 Azure 门户功能应用程序中遇到错误。

错误 CS0103:名称“ZipFile”在当前上下文中不存在

我尝试使用 nuget.exe 安装 System.IO.Compression.FileSystem.dll,但我也无法添加该软件包。错误如下。

D:\home\site\wwwroot 找不到包 'System.IO.Compression.FileSystem.dll'

请帮帮我。

谢谢。

【问题讨论】:

  • 您需要通过标准的 AddReference 菜单选项添加引用并搜索 dll。

标签: c# azure azure-functions


【解决方案1】:

如下添加程序集和导入命名空间。它对我有用。

#r "System.IO.Compression.FileSystem"

using System.IO.Compression;

【讨论】:

  • 你知道为什么会这样吗?此程序集不在the list of available assemblies...
  • @Mikhail 找到一个解释,你可以检查它是否正确。似乎该文档没有列出所有可用的程序集。我发现ZipFile 在本地C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1 中使用System.IO.Compression.FileSystem.dll,我还在这里找到System.CoreSystem.XML 等。在门户D:\... 上也是如此。所以我假设程序集可能来自这个文件夹和函数 cli 文件夹。
【解决方案2】:

感谢所有回答。 我找到了答案。 我从控制台下载了 .dll 文件, nuget.exe 安装 40-System.IO.Compression.FileSystem 下载后,添加参考库

#r "..\40-System.IO.Compression.1.0.0.2\lib\net40-client\System.IO.Compression.dll"

#r "..\40-System.IO.Compression.FileSystem.1.0.0.2\lib\net40-client\System.IO.Compression.FileSystem.dll"

之后,错误被删除。

谢谢大家。

【讨论】:

    猜你喜欢
    • 2019-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多