A.. Net Program, which involves calling com components. After the call, if some small test programs continue to run, everything is normal, but when the form program with GUI continues to run, the following exceptions always occur:
Exception: System. ArithmeticException
Message: overflow or underflow occurs in arithmetic operations.
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
It took me a day to solve the problem by looking for information everywhere. The following is my solution:
1. Declare a DLL for use
[DllImport ("msvcr70.dll", CallingConvention = CallingConvention. Cdecl)]
Unsafe public static extern int _ controlfp (int n, int mask );
2. Add the following code methods to the Code:
Internal void ResetFPCR ()
{
Const int _ EM_OVERFLOW = 0x0009001F;
Const int _ MCW_EM = 0x000FFFFF;
_ Controlfp (_ EM_OVERFLOW, _ MCW_EM );
}
3. After calling the com component, call the preceding method, for example:
// Call the com component here
// Then execute the Reset method
ResetFPCR ();
Note: For details, please see http://support.microsoft.com/default.aspx? Scid = KB; EN-US; q326219 &