Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

How catch unhandled Exception in WPF Project

Closed Thread
 
Thread Tools Display Modes
Old 08-15-2007   #1 (permalink)
Horst Klein
Guest


 

How catch unhandled Exception in WPF Project


I my Forms Application I catch unhandled Exceptions this way and show them
in a custom ErrorDialog:

Public Shared Sub Main()
AddHandler System.Windows.Forms.Application.ThreadException, AddressOf
OnVitoThreadError
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf
OnVitoUnhandledError

Try
m_Application = New MyCustomApplication
m_Application.Run()
Catch ex As Exception
ErrorDialog.ShowError(ex)
End Try
End Sub


Private Shared Sub OnVitoUnhandledError(ByVal sender As Object, ByVal e As
UnhandledExceptionEventArgs)
MyErrorDialog.ShowError(ex)
If e.IsTerminating Then Environment.Exit(-1)
End Sub

Private Shared Sub OnVitoThreadError(ByVal sender As Object, ByVal e As
System.Threading.ThreadExceptionEventArgs)
LogFacade.LogCriticalError("Nicht behandelter Fehler ThreadException",
e.Exception)
MyErrorDialog.ShowError(e.Exception)
End Sub


If I do the same Sub Main in a WPF Project my Error never will shown.
What kind of Event I have to handle?

Old 08-15-2007   #2 (permalink)
Mark Moeykens
Guest


 

Re: How catch unhandled Exception in WPF Project

You may have to work with App_DispatcherUnhandledException. I was
just reading about it today, I haven't used it yet.

Take a look at http://msdn2.microsoft.com/en-us/library/ms743714.aspx
for an example of how it's implemented. It's about half way down the
page.

You can also go here for more info:
http://msdn2.microsoft.com/en-us/lib...exception.aspx

On Aug 15, 8:46 am, Horst Klein <HorstKl...@discussions.microsoft.com>
wrote:
> I my Forms Application I catch unhandled Exceptions this way and show them
> in a custom ErrorDialog:
>
> Public Shared Sub Main()
> AddHandler System.Windows.Forms.Application.ThreadException, AddressOf
> OnVitoThreadError
> AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf
> OnVitoUnhandledError
>
> Try
> m_Application = New MyCustomApplication
> m_Application.Run()
> Catch ex As Exception
> ErrorDialog.ShowError(ex)
> End Try
> End Sub
>
> Private Shared Sub OnVitoUnhandledError(ByVal sender As Object, ByVal e As
> UnhandledExceptionEventArgs)
> MyErrorDialog.ShowError(ex)
> If e.IsTerminating Then Environment.Exit(-1)
> End Sub
>
> Private Shared Sub OnVitoThreadError(ByVal sender As Object, ByVal e As
> System.Threading.ThreadExceptionEventArgs)
> LogFacade.LogCriticalError("Nicht behandelter Fehler ThreadException",
> e.Exception)
> MyErrorDialog.ShowError(e.Exception)
> End Sub
>
> If I do the same Sub Main in a WPF Project my Error never will shown.
> What kind of Event I have to handle?



Old 08-16-2007   #3 (permalink)
Horst Klein
Guest


 

Re: How catch unhandled Exception in WPF Project

Hi Mark

Thanks a lot for your answer.
I find yesterday the DispatcherUnhandledException and build a simple project
to find a way to solfe the problem.

In my application i start a new thread to show the windows.
And I think thats the reason why it dons't work (At designtime it works. on
runtime not)
Do you know how I have to handle exceptions in thread.
See my sample project in the attachment.

Best regards




Old 08-16-2007   #4 (permalink)
Mark Moeykens
Guest


 

Re: How catch unhandled Exception in WPF Project

I'm sorry Horst, unfortunately I don't know how to do this yet. I haven't
had a chance to play around in this area.

"Horst Klein" wrote:

> Hi Mark
>
> Thanks a lot for your answer.
> I find yesterday the DispatcherUnhandledException and build a simple project
> to find a way to solfe the problem.
>
> In my application i start a new thread to show the windows.
> And I think thats the reason why it dons't work (At designtime it works. on
> runtime not)
> Do you know how I have to handle exceptions in thread.
> See my sample project in the attachment.
>
> Best regards
>
>
>

Old 08-17-2007   #5 (permalink)
Horst Klein
Guest


 

Re: How catch unhandled Exception in WPF Project

Hi Mark

No problem

I have open an supportrequest to the MS-Partner boys.
To fix to Problem.

Best regards
Horst


Old 08-17-2007   #6 (permalink)
Laurent Bugnion, MVP
Guest


 

Re: How catch unhandled Exception in WPF Project

Salut Horst,

Du bist in der Schweiz, gäll? Wo schaffst du?

Laurent
PS: Du kannst auf diese Email Adresse antworten.

Horst Klein wrote:
> Hi Mark
>
> No problem
>
> I have open an supportrequest to the MS-Partner boys.
> To fix to Problem.
>
> Best regards
> Horst
>
>


--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Old 08-17-2007   #7 (permalink)
Mark Moeykens
Guest


 

Re: How catch unhandled Exception in WPF Project

Ok great!

Be sure to post what you find out.

"Horst Klein" wrote:

> Hi Mark
>
> No problem
>
> I have open an supportrequest to the MS-Partner boys.
> To fix to Problem.
>
> Best regards
> Horst
>
>
>

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unhandled Exception in Console Application AG .NET General 10 04-10-2008 09:20 AM
Vista Install Error: Exception Unknown Software Exception burntham77 Vista installation & setup 2 01-07-2008 01:39 PM
Unhandled exception at 0x779447f2 in explorer.exe: 0xC00000FD: Stack overflow. Eigil Krogh Vista General 2 06-22-2007 01:23 PM
Unhandled exception 0xC0000005 in migcore.dll when upgrading to Vi Super_Leandro Vista General 0 04-30-2007 10:12 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50