无法在ASP.NET 5 Core中使用iTextSharp

Gro*_*nis 5 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";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误:

错误CS0012类型"Uri"在未引用的程序集中定义.您必须添加对程序集'System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的引用.MyProject.ASP.NET 5.0 MyProject/Controllers\GenerateFileController.cs 17

错误CS0012类型"Stream"在未引用的程序集中定义.您必须添加对程序集'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.任何方案?

Mat*_*rey 3

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