Overflow or underflow in the arithmetic operation when showing form

C

Codemonkey

Hi,

When I first installed Visual Studio 2003, I noticed I was getting the
following error when showing a form:

A first chance exception of type 'System.ArithmeticException' occurred in
system.drawing.dll
Additional information: Overflow or underflow in the arithmetic operation

It is being thrown on the line that attempts to add the controls to the
form's controls collection (in the windows forms designer generated code
region).

Looking at the call stack, the error is occuring on the following method
call:
System.Drawing.Font.Initialize({Name="Microsoft Sans Serif"}, 8.25, Regular,
Point, 0, false)
System.Drawing.Font.Font({Name="Microsoft Sans Serif"}, 8.25, Regular,
Point, 0, false)
System.Windows.Forms.ControlPaint.FontInPoints({Name="Microsoft Sans Serif"
Size=11.0})
System.Windows.Forms.Control.get_DefaultFont()
System.Windows.Forms.Control.get_Font()
System.Windows.Forms.Control.AssignParent({AMS.UI.Controls.ctlPlantExplorer}
)
System.Windows.Forms.Control.ControlCollection.Add({System.Windows.Forms.Tre
eView})

I've searched the web for fixes for this and found out that it has something
to do with the FPU. I also found the following workaround:

----------------------
'*************************************************
' FixFPU: Fixes a bug in .net that causes Windows
' forms to mess up if the FPU not set up
'*************************************************
<System.Runtime.InteropServices.DllImport("msvcrt.dll")> _
Private Function _controlfp(ByVal IN_New As Integer, ByVal IN_Mask As
Integer) As Integer
End Function

Private Const _MCW_EW As Integer = &H8001F
Private Const _EM_INVALID As Integer = &H10

Private Sub FixFPU()
_controlfp(_MCW_EW, _EM_INVALID)
End Sub
----------------------

This is all well and good in my own application that I have the source code
for, but the bug seems to affect all .Net applications (C# ones too). If I
install a .net program and try and run it, the program crashes with the same
error.

This problem did go away for a long time on my machine, but it's back now
with a vengance. I haven't installed any major programs or changed the .net
configuration that might have caused this.

I'm using Visual Studio .net 2003 and .Net Framework 1.1. My CPU is an AMD
Athlon. I never had this problem when using the .net Framwork 1.0.

Any help would be appreciated. It's basically crippled my machine as I can't
run any .net apps.

Best Regards,

Trev.
 
Y

Ying-Shen Yu[MSFT]

Hi,
Does your program work if you boot your system in VGA mode?
If it works, probably you need start looking for other software items
installed that affect other processes running on the system i.e. hooks,
drivers, etc.

Also ,you may try using this snippet , I checked the doc of _controlfp it
seems the parameter order is should be as follows:
Private Const _MCW_EM As Integer = &H8001F
Private Const _EM_OVERFLOW As Integer = &H4

Private Sub FixFPU()
_controlfp(~_EM_OVERFLOW, _MCW_EM);
End Sub

If you still have problem on this issue, please give me more info on this
problem.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.
 
C

Codemonkey

Hi,

Upon further investigation, it seems that there was a piece of spywhere
running in the background of my machine. Once I removed it, my .net
applications started to work fine again.

It seems that it was changing the FPU mask and hooking into all applications
running on my machine - that's why it was able to cause this problem.
According to John Hornick from Microsoft, the FPU mask is a per process or
per thread setting.

I guess the moral of the story is to be careful of spywhere and using
libraries that change the FPU mask.

Thanks again for your help,

Trev.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top