tags:

views:

147

answers:

5

Some of exceptions thrown like this:

throw new Exception( errMsg );

... doest reallly stops my application!

My expectation is when I'm throwing any ex. - app shall stop immediately.
But I noticed my app throwing one ex. after another (especially when binding) instead of terminating same time

EDIT_1:
I dont have try-catch block when it can be intercept

EDIT_2:

As mentioned - this mainly happens when binding.

Eg I have object's getter checking user's privileges (GetValue method)- if not raises exception.
I can see in debugger it executing throw new Exception(...) statement but apps doesn't stop. I've also noticed exceptions are thrown as many times as many items are in bound collection...

Any idea how to force stop binding and rise real exception??

Sample code to illustrate what I'm talkin'

public  string Name {
  get { return  GetValue( name, "Name"); }
}
+1  A: 

If I understand you correctly: your app will continue to run if the thrown exception is caught as part of a try/catch block, or if you have set up an exception catch-all handler at the application level.

David Andres
+2  A: 

Exceptions only stop the application if they remain uncaught all the way to the bottom of the current stack. WPF binding is very resilient to most thrown exceptions; instead it will log failures in the output window and carry on. Whether this was a good design decision is a matter for debate...

Martin Harris
+6  A: 

Uncaught exceptions will cause your application to terminate. Its by design (at least after 2.0 was released; 1.1 had a different behavior, iirc).

They call this "failing fast." The idea is that if an exception you didn't expect (and therefore catch) is thrown, your application is in an unstable state. At this point, its better for it to crash than continue limping along.

Binds behave differently, as all binding operations (in WPF) are designed to catch all exceptions rather than take down your application. Why they made that decision is something that the WPF team would have to tell you.

Will
A: 

Without seeing other code, I can only venture a guess: Are you sure that the exception isn't been caught and handled somewhere?

Secret Agent Man
A: 

Is this exception being thrown in a child thread?

Joe
this is child process main tread of app
Maciej