A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

P

Pieter

Hi,

I have a Windows Forms application (VB.NET 2.0) which uses a Class Library
in C#.
The application runs fine, but when I run it in debug mode, I get several "A
first chance exception of type 'System.ArgumentOutOfRangeException' occurred
in mscorlib.dll" -exceptions that are shown in the Immediate window of
Visual Studio 2005.

I want to get rid of these exceptions, but I can(t find where they occur.

Is there a way to put an UnhandledException-handler somewhere in the C#
Class Library? I'm not used to C#, and I can't find a way to do it. It
doesn't have the nice ApplicationEvents-class that my Windows Forms
application has.

Any hints, links or help will be really appreciated!

Thansk a lot in advance,

Pieter
 
A

Andreas Mueller

Pieter said:
Hi,

I have a Windows Forms application (VB.NET 2.0) which uses a Class
Library in C#.
The application runs fine, but when I run it in debug mode, I get
several "A first chance exception of type
'System.ArgumentOutOfRangeException' occurred in mscorlib.dll"
-exceptions that are shown in the Immediate window of Visual Studio
2005.

I want to get rid of these exceptions, but I can(t find where they
occur.

Is there a way to put an UnhandledException-handler somewhere in the
C# Class Library? I'm not used to C#, and I can't find a way to do
it. It doesn't have the nice ApplicationEvents-class that my Windows
Forms application has.

Any hints, links or help will be really appreciated!

Thansk a lot in advance,

Pieter

From you post I read that the application is running without any
unhandled exceptions outside of a debugger.

Have you "Break on exception thrown" enabled (Debug->Exceptions->Common-
runtime-.. Checkbox on for "thrown") ?
If so, you debbuger will break on any exception that is thrown, no
matter if it was handled or not.

HTH,
Andy
 
P

Pieter

Thanks! That helps me alreaddy a lot!

And any idea how to add somewhere handler for unhandled exceptions during
runtime? (not debug).

Pieter
 
A

Andreas Mueller

Pieter said:
Thanks! That helps me alreaddy a lot!

And any idea how to add somewhere handler for unhandled exceptions
during runtime? (not debug).

Pieter

There is a minimum of two events you must hook for a winform app:
System.Windows.Forms.Application.ThreadException
&
System.AppDomain.UnhandledException

HTH, Andy
 

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