gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 23:14:08 25 4
gpt4 key购买 nike

我正在尝试将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com