We have implemented one WPF application for one of the client. It was implemented in .NET Framework 4.5 and vs 2015. The client identified the one major issue. That was if he stops using application for some time and later if he continues in the same instance the application becoming unresponsible. We are unable to find out the root cause.
Could you please someone help us to move forward.
As @Tobias Moe Commented, it might be a memory leak issue. However, your application seems like it doesn't handle all exceptions that's why it crashes.
Handle Application.DispatcherUnhandledException Event to process unhandled exceptions. This exception specifically occures when an exception is thrown by an application but is not handled. MSDN
In your App.xaml put the DispatcherUnhandledException event;
<Application x:Class="Travelport.UniversalDesktop.Shell.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:compui="http://schemas.travelport.com/CompositeUI"
ShutdownMode="OnExplicitShutdown"
xmlns:SRD="clr-namespace:Travelport.UniversalDesktop.Common.Controls.Helpers;assembly=Travelport.UniversalDesktop.Common.Controls"
DispatcherUnhandledException="Application_DispatcherUnhandledException">
In you App.xaml.cs put in this, it should catch any unhandled UI Thread errors:
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
new MessageBoxService().Show(e.Exception.StackTrace, e.Exception.Message);
if (System.Diagnostics.Debugger.IsAttached)
{
System.Diagnostics.Debugger.Break();
}
e.Handled = true;
}
This will catch any Unhandled Errors from a custom thread:
Override the OnStartup in App.xaml.cs and add this line:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Application_UnhandledException);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.