Windows Vista Forums

How catch unhandled Exception in WPF Project

  1. #1


    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?


      My System SpecsSystem Spec

  2. #2


    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?




      My System SpecsSystem Spec

  3. #3


    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





      My System SpecsSystem Spec

  4. #4


    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
    >
    >
    >


      My System SpecsSystem Spec

  5. #5


    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



      My System SpecsSystem Spec

  6. #6


    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

      My System SpecsSystem Spec

  7. #7


    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
    >
    >
    >


      My System SpecsSystem Spec

How catch unhandled Exception in WPF Project

Similar Threads
Thread Forum
HELP! Microsoft .Net Framework Unhandled Exception error
Help! whenever i start up my laptop i get this error and i have no idea what to do. i havent made any changes to my laptop recently apart from...
General Discussion
Microsoft .Net Framework Unhandled Exception error
Help! whenever i start up my laptop i get this error and i have no idea what to do. i havent made any changes to my laptop recently apart from...
Drivers
Microsoft .NET Framework Unhandled exception......
First Hello, I'm new here and to Vista. I purchased my wife a new Toshiba Laptop for Mothers Day and here we are w/ an error already. I've never...
General Discussion
Unhandled Exception has occured in your application
C:/Users/James_2/Desktop/Error There are several of my appplications I am trying to run but the following error keeps appearing (Im not sure if...
General Discussion
Unhandled Exception in Console Application
Can anyone point me to an example or info on handling unhandled exceptions in a console application? Preferrably VB. Thanks, -- AG Email:...
.NET General
WCF: Generic unhandled exception logging
I am writing a WCF web service hosted under IIS and have several interfaces and numerous methods. I need to log any unhandled exceptions that...
Indigo
Unhandled exception 0xC0000005 in migcore.dll when upgrading to Vi
When upgrading from Windows XP to Windows Vista Ultimate Edition, the following error occurs: FatalError PANTHR Unhandled exception (code...
Vista General