首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >IText7在.NET 5上抛出FileNotFoundException

IText7在.NET 5上抛出FileNotFoundException
EN

Stack Overflow用户
提问于 2021-03-03 13:23:32
回答 1查看 630关注 0票数 0

IText7 Version : 7.1.14

我们检测到不能在IText7 5中使用.NET 5:

代码语言:javascript
运行
复制
private byte[] BuildPDF()
{
   using(var stream = new MemoryStream())
   {
        PdfDocument pdfDoc = new PdfDocument(new PdfWriter(stream));
        Document doc = new Document(pdfDoc);

        Table table = new Table(UnitValue.CreatePercentArray(8)).UseAllAvailableWidth();

        for (int i = 0; i < 16; i++)
        {
           table.AddCell("hi");
        }

       doc.Add(table);

       doc.Close();
   
       return stream.ToArray();
   }
}

这个简单的代码正在.NET Core3.1Project上工作,但是不是工作在.NET 5项目上。

引发的Exception如下所示:

代码语言:javascript
运行
复制
An unhandled exception occurred while processing the request.
FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions,
Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. 
The system cannot find the file specified.

iText.IO.Util.ResourceUtil.LoadITextResourceAssemblies()

TypeInitializationException: The type initializer for 'iText.IO.Util.ResourceUtil' threw an exception.

iText.IO.Font.Type1Parser.GetMetricsFile()

一个.dll找不到,但是如何解决这个问题,或者如何向IText7报告一个bug?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-04 07:40:47

您可以在上面的链接上手动安装https://www.nuget.org/packages/Microsoft.DotNet.PlatformAbstractions/ (Microsoft.DotNet.PlatformAbstractions)数据包,也可以从项目解决方案上的Manage包中手动安装。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66457984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档