Improper WinRT exception behavior

被刻印的时光 ゝ 提交于 2020-01-07 04:18:08

问题


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



来源:https://stackoverflow.com/questions/44100603/improper-winrt-exception-behavior

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!