c# - 无法将 iTextSharp 与 ASP.NET 5 Core 一起使用

标签 c# asp.net asp.net-mvc itextsharp asp.net-core

我正在尝试将 iTextSharp 与 ASP.NET 5 Core 结合使用。但是,当我尝试使用 iTextSharp 5.5.5 构建 ASP.NET 应用程序时出现这些错误

代码:

using Microsoft.AspNet.Mvc;
using System.IO;
using System;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;

// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace MyNamespace
{
    public class GenerateFileController : Controller
    {
        // GET: /<controller>/
        public string Index()
        {
            PdfReader reader = new PdfReader("template.pdf");
            return "SomeText";
        }
    }
}

错误:

Error CS0012 The type 'Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. MyProject.ASP.NET 5.0 MyProject/Controllers\GenerateFileController.cs 17

Error CS0012 The type 'Stream' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. MyProject.ASP.NET Core 5.0 MyProject/Controllers\GenerateFileController.cs 17

当我试图用 ASP.NET 4.6 模板做同样的事情时,它工作正常。问题是我想为这个项目使用 ASP.NET 5 Core。有什么解决办法吗?

最佳答案

大多数现有包尚不支持 asp.net Core 5;由于存在显着差异,因此需要手动更新它们。如果您想使用 iTextSharp,您要么需要坚持使用 asp.net 5(不是 Core),要么等待 iTextSharp 的创建者发布 Core 版本。

关于c# - 无法将 iTextSharp 与 ASP.NET 5 Core 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29717625/

相关文章:

c# - Visual Studio 2008 调试 - 跳过代码

.net - 模型类中定义的 ASP MVC HttpPostedFile

c# - 从 Entity Framework 中自动生成的类继承

jquery - 使用 jQuery jsonp 跨域调用 ASP.NET Web 服务

c# - System.Data.SQLite 无法加载扩展

asp.net-mvc - 从现有 MVC 创建

c# - 参数的 Swagger 默认值

c# - 无法在 Linux Mint 上使用 monodevelop 通过 C# 发送邮件

c# - 如何在 Entity Framework 4.3 中禁用模型兼容性检查?

jquery - asp.net 页面导航历史记录