Skip to content

Aspose.Cells 19.x 版的 System.IO.FileLoadException 异常

🏷️ Aspose

使用最新版的 Aspose.Cells 在创建 workbook 时发生了异常。
项目目标框架 .NET Core 2.1

batch
Install-Package Aspose.Cells -version 19.3.0
csharp
var workbook = new Aspose.Cells.Workbook(templetPath);
csharp
System.IO.FileLoadException
  HResult=0x80131040
  Message=Could not load file or assembly 'System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=Aspose.Cells
  StackTrace:
   at  ​.()
   at  ​.()
   at   ..ctor(Cells )
   at Aspose.Cells.Cells.()
   at Aspose.Cells.Worksheet..ctor(WorksheetCollection )
   at Aspose.Cells.WorksheetCollection.Add()
   at    . (    )
   at    .(    , Boolean )
   at    .       ()
   at    .()
   at    .(Workbook , LoadOptions , Boolean )
   at   .(String , Stream , LoadOptions )
   at Aspose.Cells.Workbook.(String , LoadOptions )
   at ExcelSample.Program.Main(String[] args) in C:\Users\liujiajia\source\repos\ExcelSample\ExcelSample\Program.cs:line 14

案一

安装最新版的 System.Drawing.CommonSystem.Text.Encoding.CodePages 包。

batch
Install-Package System.Drawing.Common -version 4.5.1
Install-Package System.Text.Encoding.CodePages -version 4.5.1

案二

降到 18.x 版。

batch
Install-Package Aspose.Cells -version 18.12.0

Evaluation Warning

如果没有 Licence 的话生成的文件会附带一个 Evaluation Warning 的 Sheet。

Evaluation Warning
Evaluation Only. Created with Aspose.Cells for .NET.Copyright 2003 - 2018 Aspose Pty Ltd.

如果要去掉这个警告可以在 这里 下载破解版的 dll(18.10.0)。
不过还是推荐购买正版 => Aspose.Cells for .NET
引用这个 dll 后也需要单独安装 System.Drawing.CommonSystem.Text.Encoding.CodePages 包。