Catch exception when accessing Application::Current in WindowsRTPlatformEventHandler deconstructor like in the constructor as both have the same risk of throwing the exception
@@ -62,6 +62,8 @@ namespace Microsoft {
}
PlatformEventHandler::~PlatformEventHandler()
+ {
+ try
{
if (this->m_suspendToken.Value != 0)
{
@@ -78,6 +80,11 @@ namespace Microsoft {
Application::Current->UnhandledException -= this->m_unhandledExceptionToken;
}
}
+ catch (Exception^ e)
+ {
+ // Access to Application::Current can generate COM exceptions.
+ }
+ }
void PlatformEventHandler::OnSuspending(Object ^ sender, SuspendingEventArgs^ e)
{
