I observe very strange exception handling behavior in any Windows 8.1 (WinRT) application. I've created default project "Blank App (Windows 8.1)", declared MyException exception class and throw it in button's click event handler. I have submitted to Application.UnhandledException event and trying to get the type of received exception. Sometimes it is my exception, sometimes it is common System.Exception. Sometimes debugger shows it is common Exception but application works as it would be MyException: Question is "How to make a WinRT application to work the same way as .NET application in context of exceptions, and as it is declared by winRT documentation? I want to receive exception object that I have thrown".
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I should save UnhandledExceptionEventArgs.Exception value to a variable before reading any properties of UnhandledExceptionEventArgs class. After that you can access any information (like stack trace) at any moment by reading your variable value(not UnhandledExceptionEventArgs.Exception value). That behavior seems to be an issue so I reported it: https://connect.microsoft.com/VisualStudio/feedback/details/3134547/windows-rt-8-1-unhandledexceptioneventargs-issue