torpederos
torpederos

Reputation: 841

wpf unhandled exception

In my WPF application some users get "application generated an exception that can not handle" error. I've implemented Application.DispatcherUnhandledException event handler but the the exception isn't handled by this event. Is there any possibility that exception occurs outside application causing closing my application, maybe something with memory?

Upvotes: 2

Views: 2923

Answers (4)

IvanH
IvanH

Reputation: 5139

If your handler is called but exception remains unhandled, it is necessary to handle the event: e.Handled=true; see: How to suppress UI exceptions in wpf?

Upvotes: 0

Dean Chalk
Dean Chalk

Reputation: 20451

In my experience if only some users get the error (and those users get the error all the time), then it is likely that the project file references dll's without setting the 'CopyToLocal' property to true - therefore assuming that all users have the dll's installed in the GAC - which may not be the case for some users.

Upvotes: 0

Dummy01
Dummy01

Reputation: 1995

Did you try add also this to your Application Startup?:

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

Upvotes: 2

Tomas McGuinness
Tomas McGuinness

Reputation: 7691

One thing you could try, in addition to the DispatcherUnhandledException is to listen for exceptions coming from the AppDomain

AppDomain.CurrentDomain.UnhandledException += 
        new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

This should, in theory, catch all exceptions related to your application and not just ones running within the Dispatcher.

Upvotes: 6

Related Questions