您的位置:首页 > 其它

.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目录下
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: