Reputation: 3860
Is there a way in Windows Mobile to catch global unhandled exceptions? If not, are there any workarounds? Specifically, we have a thin client app and we want to globally catch exceptions generated when the network is unavailable (so we can present a friendly message and prompt the user to try again).
This catch statement doesn't fire when I throw an exception on button press
try
{
Application.Run(new Login());
}
catch (Exception ex)
{
Debug.WriteLine("Caught " + ex);
}
Upvotes: 3
Views: 692
Reputation: 67168
You can use an AppDomain.UnhandledException handler, but you cannot recover from it - you can only log it and shutdown the app. There's no way to have a global handler that is recoverable (at least in the CF) because there's no way to guarantee app state at that point.
Upvotes: 2
Reputation: 37660
Create a static void Main(), and add a try/catch that surround everything in the method body.
Upvotes: 0