Improper WinRT exception behavior

2019-08-19 10:05发布

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: Strange Exception 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条回答
地球回转人心会变
2楼-- · 2019-08-19 10:35

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

查看更多
登录 后发表回答