By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,180 Members | 1,051 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,180 IT Pros & Developers. It's quick & easy.

C# Overflow error! Any help?

P: n/a
Thanks Derek...

Okay i had another question..

my program runs smoothly for the first minute, after 1
minute...

suddenly it breaks and display this error:

do you know what is the cause of this problem...

i had check my codes and confirm it is working.. shouldn't
be a problem on logic side

An unhandled exception of type 'System.OverflowException'
occurred in system.windows.forms.dll
Additional information: Overflow error.

Any help?

Regards,
Chua Wen Ching :p
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Chua Wen Ching <cw*@cwc.com> wrote:
Okay i had another question..

my program runs smoothly for the first minute, after 1
minute...

suddenly it breaks and display this error:

do you know what is the cause of this problem...

i had check my codes and confirm it is working.. shouldn't
be a problem on logic side

An unhandled exception of type 'System.OverflowException'
occurred in system.windows.forms.dll
Additional information: Overflow error.

Any help?


Without you posting some code, it's almost impossible to say. I suggest
you pare down your code to a short but complete example which
demonstrates the problem - see
http://www.pobox.com/~skeet/csharp/complete.html for what I mean. You
may well find the problem just by going through this exercise, but if
not, posting that code will help immensely.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #2

P: n/a
This usually happens when you have a recursive function
call in your code that never ends and uses up all the
memory.

I had the problem once when I accidentally did this:

private bool member = false;

public bool Member
{
get
{
return Member; // instead of return member
}
}

check for that sort of situation
-----Original Message-----
Thanks Derek...

Okay i had another question..

my program runs smoothly for the first minute, after 1
minute...

suddenly it breaks and display this error:

do you know what is the cause of this problem...

i had check my codes and confirm it is working.. shouldn'tbe a problem on logic side

An unhandled exception of type 'System.OverflowException'occurred in system.windows.forms.dll
Additional information: Overflow error.

Any help?

Regards,
Chua Wen Ching :p
.

Nov 15 '05 #3

P: n/a
"Chua Wen Ching" <cw*@cwc.com> wrote in message
news:07****************************@phx.gbl...
An unhandled exception of type 'System.OverflowException'
occurred in system.windows.forms.dll
Additional information: Overflow error.


This is an exception thrown when the arithmetic operation results in
overfow. for instance:

byte b = 255;
b += 3; // overflow!
Nov 15 '05 #4

P: n/a
By default, C# will not check arithmetic for overflow.
Using this code as an example:

//example.cs
class Example
{
static void Main()
{
int number = int.MaxValue;
Console.Writeline(++number)
}
}

Suppose: number == -2147483648 ----> It will not get any error message.

If you're getting the System.OverflowException, your arithmetic overflow checking is turned on ( Ex.: c:\ csc /checked+ example.cs).

Solution 1 : Try turning it off .
Example:
c:\ csc /checked- example.cs -- will wrap the int value to int.MinValue and not cause the System.Overflow Exception.

Solution 2: Use Uncheck Statement

//example.cs
class Example
{
static void Main()
{
unchecked ---> all statements are never checked for arithmetic overflow
{
int number = int.MaxValue;
Console.Writeline(++number)
}
}
}

Solution 3: use unchecked statement

//example.cs
class Example
{
static void Main()
{
int number = int.MaxValue;
Console.Writeline(unchecked(++number)); ---> expression is checked for aruthmetic overflow
}
}
Hope this helps! :D

===================
A


"Chua Wen Ching" <cw*@cwc.com> wrote in message news:07****************************@phx.gbl...
Thanks Derek...

Okay i had another question..

my program runs smoothly for the first minute, after 1
minute...

suddenly it breaks and display this error:

do you know what is the cause of this problem...

i had check my codes and confirm it is working.. shouldn't
be a problem on logic side

An unhandled exception of type 'System.OverflowException'
occurred in system.windows.forms.dll
Additional information: Overflow error.

Any help?

Regards,
Chua Wen Ching :p

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.