Hobbyistprogrammer-7674 avatar image
0 Votes"
Hobbyistprogrammer-7674 asked DewayneBasnett-7583 commented

Arithmetic operation resulted in an overflow - Only in Release mode


I have a simple Object read-only Property "Length " which gives me an Arithmetic operation that resulted in an overflow, the application runs without any problem or error when "Debug and AnyCPU" are set. But it gives an error when I set it to Release & AnyCPU.

Whatever the if statement to make sure if the Num & Num2 are greater than 0 does not help. Any idea how to solve this problem?

 Public Class Test
 Public Property Num2 as integer
 Public Readonly Property Length as long?
            Dim Num as long
            Return  Num * (Num2 /100)
     End Get
 End property
 End Class


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I can't get the exception you mention. Can you illustrate the use of the Class that does give the exception.

EDIT: are you accessing the Class within a loop somewhere?

0 Votes 0 ·

As written it looks like the getter could only return zero if the return statement were correct. You have an implied conversion from double.

0 Votes 0 ·

0 Answers