使用Spire组件抛出异常The type initializer for 'spr857' threw an exception

我使用免费的Spire.Xls组件尝试去转换Excel文档到PDF文档,在执行下面第二行代码,也就是做加载文档这步时,抛出了异常“The type initializer for 'spr857' threw an exception

Workbook workbook = new Workbook();

workbook.LoadFromFile("D:\\sample.xlsx");

workbook.SaveToFile("D:\\sample.pdf", Spire.Xls.FileFormat.PDF);

这个问题困扰了我老半天,在网上也没搜到它的解决方案,后来访问了E-iceblue公司的论坛,才找到了它的解决方案,E-iceblue 公司的技术人员回复的说是:please make sure Spire.pdf.dll file is placed in the same location as Spire.xls.dll.

根据这个意思我尝试了两种方案,都能解决这个问题,在这里分享一下:

方案1,将Spire.Xls包里的Spire.pdf.dll文件拷贝到Spire.Xls.dll相同的目录下。

方案2,将Spire.XLS.dll和Spire.Pdf.dll同时作为Reference导入到项目里。

转换出来的结果真是完美极了:

原始的Excel:

转换出来的PDF:

在使用Spire.Xls的同时,我也在尝试使用免费的Spire.Doc去做Word文档到PDF文档转换时,遇到了相同的问题,上面的两个方案也适用在Spire.Doc组件中。

使用Spire组件抛出异常The type initializer for 'spr857' threw an exception的更多相关文章

  1. ASP.Net Core "The type initializer for 'Gdip' threw an exception"

    ASP.NET Core项目部署在Linux下可能会出现GDI错误 The type initializer for 'Gdip' threw an exception 解决方案:创建 libdl 的 ...

  2. System.Drawing Linux Centos7 The type initializer for 'Gdip' threw an exception

    System.Drawing 在linux使用时提示异常 The type initializer for 'Gdip' threw an exception 解决方案: yum install au ...

  3. .net Core 在 CentOS7下,报The type initializer for 'Gdip' threw an exception.异常

    .net Core允许在 Centos7 上,使用 System.Draw.Common类库时,报以下错误: "Class":"System.TypeInitializa ...

  4. the type initializer for '' threw an exception

    the type initializer for '' threw an exception 问题:程序启动时初始化主窗口类时,弹出该错误.调查:查看类的构造函数是否会有异常抛出.解决:去掉类的构造函 ...

  5. C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析与解决方法

    对于C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析,目前本人分析两种情况,如下: 情况一: 借鉴麒麟.NET ...

  6. skiasharp在阿里云Windows server 2016上部署时提示The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception. 错误

    应用环境及问题描述: Windows Server 2016,.Net core 2.1, Skiasharp作为跨平台的图像处理组件在生成缩略图时出错,本地测试都是正常的,部署到服务器无法生成缩略图 ...

  7. System.Security.SecurityException The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception

    [15/08/19 00:03:10] [DataManager-7292-ERROR] System.Reflection.TargetInvocationException: Exception ...

  8. System.TypeInitializationException: The type initializer for 'Mono.Unix.Native.Stdlib' threw an exception.

    08-31 17:02:03: ### DEBUG ##########################System.TypeInitializationException: The type ini ...

  9. debian The type initializer for 'System.Drawing.KnownColors' threw an exception

     Change the "System.Drawing" reference of "CoreCompat.System.Drawing"if you thro ...

随机推荐

  1. Codeforces Round #361 (Div. 2) B

    B - Mike and Shortcuts Description Recently, Mike was very busy with studying for exams and contests ...

  2. JQuery对象与DOM对象的区别与转换

      1.jQuery对象和DOM对象的区别 DOM对象,即是我们用传统的方法(javascript)获得的对象,jQuery对象即是用jQuery类库的选择器获得的对象; eg: var domObj ...

  3. RunLoop(基本操作)

    基本概念 -(void)runTimerInThread { //NSAutoreleasePool,没的用 [NSTimer scheduledTimerWithTimeInterval:1.0 t ...

  4. Excel数据导入数据库的SQL快速生成

    =CONCATENATE("insert into table_name(id, code, name, remark) values (uuid(),'",B2,"', ...

  5. apache 使用htaccess自定义路由机制

    先开启伪静态.详情查看这篇文章:http://www.cnblogs.com/CyLee/p/5544119.html 然后在项目根目录中新建一个.htaccess文件,加入以下代码 正则中()的变量 ...

  6. 如何创建一个Edge 浏览器扩展

    随着微软Windows 10 年度更新的发布,数次延宕的Edge 扩展功能终于得到了官方正式支持.我在我的另外一个博客上发布了如何创建一个Edge 浏览器扩展的博文,链接如下: https://blo ...

  7. ASP.NET关于对excel数据导入到数据库

    //*******************************C#(UI代码)********************************/ Web界面上放一个FileUpload 名称为:F ...

  8. 什么情况下才要重写Objective-C中的description方法

    特别注意: 千万不要在description方法中同时使用%@和self,同时使用了%@和self,代表要调用self的description方法,因此最终会导致程序陷入死循环,循环调用descrip ...

  9. C#基础_单例模式

    控制某个类型的实例数量-唯一一个 class Program { static void Main(string[] args) { test t1 = test.GetInstance(); tes ...

  10. 浅析用Base64编码的图片优化网页加载速度

    想必大家都知道网页加载的过程,从开始请求,到加载页面,开始解析和显示网页,遇到图片就再次向服务器发送请求,加载图片.如果图片很多的话,就会产生大量的http请求,从而影响页面的加载速度.所以现在有一种 ...