.Net中使用com组件后发生System.ArithmeticException异常的解决办法(Message=算术运算中发生溢出或下溢。)
2016-06-02 17:58
633 查看
最近在开发一个.Net程序,其中涉及到对com组件的调用,或者第三方DLL调用,
在调用完以后如果使用一些小的测试程序继续运行,一切正常,但是在使用带有GUI的form程序,或者WPF程序中,继续执行时,总是出现以下异常Exception: System.ArithmeticExceptionMessage: 算术运算中发生溢出或下溢。
“设置属性“System.Windows.FrameworkElement.Height”时引发了异常。”,行号为“6”,行位置为“14”。
在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
在 System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
在 System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
在 Evidence.MVVM.Views.WinIdentityVeri.InitializeComponent() 位置 E:\Win.xaml:行号 1 解决方法: 1.声明一个DLL掉用 [DllImport("msvcr71.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int _controlfp(int n, int mask);
internal void ResetFPCR()
{
const int _EM_OVERFLOW = 0x0009001F;
const int _MCW_EM = 0x000FFFFF;
_controlfp(_EM_OVERFLOW, _MCW_EM);
} 2.在调用完com组件后,调用以上方法,如: //这里调用com组件 //然后执行Reset方法 ResetFPCR(); 如果没有msvcr71.dll 从网上下载 然后放到bin目录下
在调用完以后如果使用一些小的测试程序继续运行,一切正常,但是在使用带有GUI的form程序,或者WPF程序中,继续执行时,总是出现以下异常Exception: System.ArithmeticExceptionMessage: 算术运算中发生溢出或下溢。
“设置属性“System.Windows.FrameworkElement.Height”时引发了异常。”,行号为“6”,行位置为“14”。
在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
在 System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
在 System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
在 Evidence.MVVM.Views.WinIdentityVeri.InitializeComponent() 位置 E:\Win.xaml:行号 1 解决方法: 1.声明一个DLL掉用 [DllImport("msvcr71.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int _controlfp(int n, int mask);
internal void ResetFPCR()
{
const int _EM_OVERFLOW = 0x0009001F;
const int _MCW_EM = 0x000FFFFF;
_controlfp(_EM_OVERFLOW, _MCW_EM);
} 2.在调用完com组件后,调用以上方法,如: //这里调用com组件 //然后执行Reset方法 ResetFPCR(); 如果没有msvcr71.dll 从网上下载 然后放到bin目录下
相关文章推荐
- 阅读下面程序,请回答如下问题:
- Linux常用命令--more
- 键盘记录器
- 各种浏览器内核的比较
- Facebook推荐系统的原理、性能及使用情况
- Hadoop安装教程_单机/伪分布式配置_CentOS6.4/Hadoop2.6.0
- 如何解决访问页面路径不正确的问题
- HDU 1197 Specialized Four-Digit Numbers (枚举+进制转化,简单)
- 点击图片产生水波的动画效果代码展示
- 设置QPushButton的平面与突出(遍历控件)
- 第二阶段团队项目冲刺第十天
- android开发笔记之网络编程—使用TCP协议和URL进行网络编程
- bitmap格式分析
- 类与对象及继承多态
- Struct和Class的区别
- Powershell学习之道-文件夹共享及磁盘映射
- 对某APP的逆向之旅(1)
- 指针数组和数组指针
- 第9周课后实践 阅读程序,请写出这些程序的运行结果(1)
- activity切换动画 右边进入右边出