当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > .Net中使用com组件后发生System.ArithmeticException异常的解决办法

ASP.NET
如何在ASP.NET中使用SmtpMail发送邮件
在VB.NET中利用Split和Replace函数计算字数
Attribute应用:简化ANF自定义控件初始化过程
ASP.NET 2.0移动开发入门之使用样式
ASP.NET 2.0中使用OWC生成图表
ASP.NET 2.0中控件的简单异步回调
一个无法捕获ADO.NET Dataset的内存错误
深入解读ADO.NET2.0的十大最新特性
.Net平台下的分布式缓存设计
ASP.NET全局异常处理浅析
ASP.NET 2.0中文验证码的实现
浅析.NET平台编程语言的未来走向
.net 框架程序设计收藏
使用ASP.NET MVC Futures 中的异步Action
详解.NET中的XmlReader与XmlWriter
关于.NET中的Server push技术
asp.net页面执行机制
对比JSP和ASP.NET的存储过程
.NET 4.0不会包含System.Shell.CommandLine
ASP.NET十个有效性能优化的方法

ASP.NET 中的 .Net中使用com组件后发生System.ArithmeticException异常的解决办法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 159 ::
收藏到网摘: n/a


最近在开发一个.Net程序,其中涉及到对com组件的调用,在调用完以后如果使用一些小的测试程序继续运行,一切正常,但是在使用带有GUI的form程序继续执行时,总是出现以下异常Exception: System.ArithmeticExceptionMessage: 算术运算中发生溢出或下溢。Source: System.Drawing at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet) at Payment.Phone.ErrorForm.InitializeComponent() in E:\cvsroot\develope\payment\Phone\ErrorForm.cs:line 108 at Payment.Phone.ErrorForm..ctor(Util util, String msg) in E:\cvsroot\develope\payment\Phone\ErrorForm.cs:line 139 at Payment.Phone.ConfirmForm.lblNext_Click(Object sender, EventArgs e) in E:\cvsroot\develope\payment\Phone\ConfirmForm.cs:line 212
后来到处找资料,花了我一天的时间才给解决,以下是我的解决办法:1.声明一个DLL掉用 [DllImport("msvcr70.dll", CallingConvention = CallingConvention.Cdecl)] unsafe public static extern int _controlfp(int n, int mask);2.在代码中添加以下代码方法 internal void ResetFPCR() { const int _EM_OVERFLOW = 0x0009001F; const int _MCW_EM = 0x000FFFFF; _controlfp(_EM_OVERFLOW, _MCW_EM); }3.在调用完com组件后,调用以上方法,如: //这里调用com组件 //然后执行Reset方法 ResetFPCR(); 注:具体详细请看http://support.microsoft.com/default.aspx?scid=KB;EN-US;q326219&