views:

26

answers:

2

I'm using a 3rd party library (Fluent NHibernate) that throws a harmless "file not found" exception on startup when I run with "break on all Common Language Runtime Exceptions" enabled (Debug | Exceptions... menu).

I realize I could just uncheck the specific "file not found" exception, but then I wouldn't get a break if this occured somewhere else in my code.

Is there any way (pragma? attribute?) to suppress the exception, but only in the one place I know it will occur?

+1  A: 

I don't think there is an option for this in VS, but maybe someone else knows of a way.

As an alternative, you could:

  • disable the exception
  • put a break point at the beginning of your code
  • run the program to your break-point
  • reenable that exception and continue.

However, this is manual, and doesn't meet your needs as being a permanent solution.

Jess
Thanks, but I'm looking for a way to suppress the exception in a way that's "permanent" i.e. I want to avoid any manual steps that have to be performed every time I run my program in the debugger.
Tom Bushell
I don't think its possible then, but maybe someone else knows of a way.
Jess
Post that as an answer, and I'll give you an upvote (Hans was first, but he's already got almost 100k rep ;-)
Tom Bushell
I just edited this post to be more appropriate and save space. Thanks a bunch! :)
Jess
+2  A: 

After a bit of digging and SO browsing of releated questions, I solved the problem via a different route.

Turns out I had the "Enable Just My Code..." option turned off (it's in Tools/Options/Debugging). Turning this option on also adds a "User Unhandled" column to the Exceptions dialog.

I checked the User Unhandled box beside Common Language Runtime Exceptions, and unchecked everything else.

Now, the debugger ignores the exceptions from the 3rd party library, but breaks on exceptions that don't have local handlers in my code - exactly what I wanted.

Tom Bushell