使用Spire组件抛出异常The type initializer for 'spr857' threw an exception
使用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的更多相关文章
- 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 的 ...
- 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 ...
- .net Core 在 CentOS7下,报The type initializer for 'Gdip' threw an exception.异常
.net Core允许在 Centos7 上,使用 System.Draw.Common类库时,报以下错误: "Class":"System.TypeInitializa ...
- the type initializer for '' threw an exception
the type initializer for '' threw an exception 问题:程序启动时初始化主窗口类时,弹出该错误.调查:查看类的构造函数是否会有异常抛出.解决:去掉类的构造函 ...
- C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析与解决方法
对于C#中异常:“The type initializer to throw an exception(类型初始值设定项引发异常)”的简单分析,目前本人分析两种情况,如下: 情况一: 借鉴麒麟.NET ...
- skiasharp在阿里云Windows server 2016上部署时提示The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception. 错误
应用环境及问题描述: Windows Server 2016,.Net core 2.1, Skiasharp作为跨平台的图像处理组件在生成缩略图时出错,本地测试都是正常的,部署到服务器无法生成缩略图 ...
- 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 ...
- System.TypeInitializationException: The type initializer for 'Mono.Unix.Native.Stdlib' threw an exception.
08-31 17:02:03: ### DEBUG ##########################System.TypeInitializationException: The type ini ...
- debian The type initializer for 'System.Drawing.KnownColors' threw an exception
Change the "System.Drawing" reference of "CoreCompat.System.Drawing"if you thro ...
随机推荐
- centos 6.5 升级内核 linux 3.12.17 (笔记 实测)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G) 系统版本:Linux centos 2.6.32-431.el6.x86_64(Centos-6.5-x86_64-mi ...
- 原来scanf读入字符串还能这样..
(本文针对于NOIP Day1 玩具迷题) (这是弱鸡写的)(字符串用char二维,本质一样的) 在NOIP成功AC了这道题,结果OJ上被string卡了时间,没办法只能用scanf了.....百度看 ...
- DNS域名服务器
DNS是用来解析域名的,IP就相当于地址一样,不知道IP就没法访问指定网络.要上PC6下载站,输入www.pc6.com, 得先问问DNS大哥www.pc6.com在哪,然后Dns告诉你后,就上去了w ...
- 【codevs】刷题记录→_→(推荐看!)
注:本文是我原先在csdn内写的一篇博文,现转到这里,两篇博文尽量同时更新. //#include<iostream->shuati> //define 为什么刷 学长☞hzwer ...
- maven web项目中web.xml
web.xml 不是web工程必须的. web.xml文件用来配置那些东西:欢迎页,servlet,filter等. web.xml文件中定义了多少种标签元素,web.xml 中就可以出现它的模式文件 ...
- CYQ.Data V5 MDataTable 专属篇介绍
前言 以前一两个月才出一篇,这三天有点变态地连续1天1篇(其实都是上周末两天写好的存货). 短期应该没有新的和此框架相关的文章要写了,这应该是最后一篇,大伙且看且珍惜. 前两篇讲数据库读写分离和分布式 ...
- ESENT分布式数据存储
关于ESENT,我能想到最恰当的比喻是,它是Microsoft世界的BerkeleyDB,鲜为人知,很少有.NET开发人员使用它,rhino-queues项目使用就是它,但它的性能和可靠性已经经受住了 ...
- Lesson 9 A cold welcome
Text On Wednesday evening, we went to the Town Hall. It was the last day of the year and a large cro ...
- 从viewport发现小米手机参数不一致
想要在移动web领域有所深造的小伙伴,第一关要过的就是逻辑像素与设备像素之间的关系. 初入移动web,一定要搞懂的几个单位(DPI.PPI.DP.PX 的详细计算方法及算法来源是什么?): dip(d ...
- ASP.NET MVC 5 - 给数据模型添加校验器
在本节中将会给Movie模型添加验证逻辑.并且确保这些验证规则在用户创建或编辑电影时被执行. 拒绝重复 DRY ASP.NET MVC 的核心设计信条之一是DRY: "不要重复自己(DRY ...