System.ArgumentOutOfRangeException

TomPhillips

Active member
Joined
Feb 24, 2005
Messages
33
Programming Experience
10+
System.ArgumentOutOfRangeException[RESOLVED]

My application has a form with a button that starts a thread to load data from an SQL database and then update a SYBASE database. As it progresses, it updates listboxes on the form. The problem is that at some point it errors with:
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values.
Now if I click 'continue' it goes on as if there's no problem. If I set this exeption to 'continue' in the Debug menu, I don't see the exception, but I don't like that solution.

When the exception happens, the debugger breaks the program with a line in green highlight, but it is all the way back in the .ShowDialog() line of the form which opened the current form.

Also, while the exception is certainly caused by something in the threaded module, I have been unable to find it. It does not seem to occur at the same point in the code every time.

And if I just run the module, instead of launching it as a thread, there is no problem.

Any thoughts? How do I find out what 'specified argument' it's talking about?
 
Last edited:
if bypassing the exception is all you need to do, then just use try/catch blocks so the exception will be caught then disgarded
 
Tred that.

I have not been able to catch the exception in try/catch. If I set the preference to 'continue' in the Debug->Exceptions... menu for 'System.ArgumentOutOfRange' it will avoid the problem and it doesn't have the problem when I run the .exe outside of VS.

Another symptom is that the thread has a loop that takes items from one listbox, processes them and puts them in the other listbox. If I place a breakpoint at the first line inside of the loop, the exception will not happen when I hit 'continue'.
 
Back
Top