Application.ThreadException/Enable JIT debugging

A

Armin Zingler

Teemu said:


Thanks for the links.
Yesterday I was sure that there is no relation between these two
things but that KB Article changed my opinion. That article states
that the problem shouldn't exist in VS2005 but it is not true.

This article describes it's the same with all Frameworks:
http://support.microsoft.com/kb/324653

It's really a pain..., IMO. The "cause" section describes what happens but
no reason is given. It's just unwanted behavior and there is no option to
change it. I really have to catch it an rethrow it. :-( I have no problem
with this option but I don't see why I'm forced to live with this behavior.
Well, I have to. I mean, the whole principle - which is a basic principle in
the Framework - of exception propagation is broken by this "special
feature".
I tried to create that app.config file in VB 2008 and I pasted this
code in it:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

Now that Try-Catch block works as expected without debuggers and
events related to ThreadException. If I change the boolean to False,
I get the same functionality as described yesterday.

Do you mean the catch block catches the exception now? But
that "should not" happen. I'm confused.


Armin
 
T

Teemu

"Armin Zingler" <[email protected]> kirjoitti viestissä

Do you mean the catch block catches the exception now? But
that "should not" happen. I'm confused.

Yes, when I created app.config file Try-Catch block catched exceptions
occurred during ShowDialog function. I tried this with VB2005 and VB2008 and
they both worked in the same way: Try-Catch block really worked.

-Teemu
 
T

Tom Shelton

Hi,

I've aleady asked 3 times in the Winforms group but didn't get any answer:


I'm using Framework 1.1/VS 2003 (VB.Net).

I have this code:

Try
dim f as new form1
f.showdialog
catch
'exception handling
end try

I expect that the catch block catches exceptions during the life
time of the dialog. However, it does not. Instead, the default
exception dialog of the Framework is shown. It's the one that
adivces us to enable JIT debugging in the application.exe.config or
machine.config file. Well, I've done this already. Anway, I want my
own catch block (above) handle the exception!

I've tried adding an event handler to the Application.ThreadException
event. It works, that means the handler is called instead of showing
the default exception dialog. But again, that's not what I want! How
can I have the catch block handle the exceptions thrown in the try
block?


Armin

I think after some reading this is really a limitation of windows forms. But,
you might be happy to know, that this does work in WPF.

Class Window1

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim f As Window2 = New Window2
Try

f.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
f.Close()
End Try

End Sub
End Class

Partial Public Class Window2

Private Sub Window1_Loaded(ByVal sender As System.Object, _
ByVal e As System.Windows.RoutedEventArgs) Handles Window1.Loaded
Throw New Exception("Neener neener!")
End Sub
End Class
 
A

Armin Zingler

Tom said:
I think after some reading this is really a limitation of windows
forms.

Yes. I wonder how Teemu was able to make it work!??
But, you might be happy to know, that this does work in WPF.

Class Window1

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim f As Window2 = New Window2
Try

f.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
f.Close()
End Try

End Sub
End Class

Partial Public Class Window2

Private Sub Window1_Loaded(ByVal sender As System.Object, _
ByVal e As System.Windows.RoutedEventArgs) Handles Window1.Loaded
Throw New Exception("Neener neener!")
End Sub
End Class


:) Never dealt with WPF til now. Maybe I should have a look at it. Thank
you for the suggestion.


Armin
 

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