. NET System.ArithmeticException exception occurs after using COM components (overflow or underflow in message= arithmetic operations. )

Source: Internet
Author: User
Tags baseuri

Recently in the development of a. NET program, which involves calls to COM components, or third-party DLL calls,

After the call, if you continue to run with some small test program, but when you use a form program with a GUI, or in a WPF program, the following exception exception always occurs: System.arithmeticexceptionmessage: Overflow or underflow occurs in arithmetic operations.

"Setting property" System.Windows.FrameworkElement.Height "throws an exception. ", the line number is" 6 "and the line position is" 14 ".

In System.Windows.Markup.WpfXamlLoader.Load (XamlReader xamlreader, Ixamlobjectwriterfactory writerfactory, Boolean Skipjournaledproperties, Object rootobject, xamlobjectwritersettings settings, Uri BaseUri)
In System.Windows.Markup.WpfXamlLoader.LoadBaml (XamlReader xamlreader, Boolean skipjournaledproperties, Object Rootobject, Xamlaccesslevel accessLevel, Uri BaseUri)
In System.Windows.Markup.XamlReader.LoadBaml (Stream stream, ParserContext ParserContext, Object parent, Boolean Closestream)
In System.Windows.Application.LoadComponent (Object component, Uri resourcelocator)
In Evidence.MVVM.Views.WinIdentityVeri.InitializeComponent () position E:\Win.xaml: line number 1

Workaround:

1. Declaring a DLL out of use

[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. After the COM component is called, call the method above, for example:

Calling COM components here

Then execute the Reset method

RESETFPCR ();

If no msvcr71.dll is downloaded from the web and then placed in the bin directory

. NET System.ArithmeticException exception occurs after using COM components (overflow or underflow in message= arithmetic operations. )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.