Catching unhandle exception in C++/CX

不问归期 提交于 2019-12-12 02:43:42

问题


Is it possible to catch unhandle exception in C++/CX? I found that if crash happened in C++/CX my app will terminate immediately (Application_UnhandledException not get called). What's more, I found Win32 api SetUnhandledExceptionFilter is not avaliable which is Windows API for catching unhandle exception.


回答1:


If by exception you mean structured exceptions, you probably should use __try, e.g. something like this (untested code below):

__try
{
    someCode();
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
    throw Platform::Exception::CreateException( ... );
}

Or, if you're trying to handle a C++ exception, such as exceptions from STL, then you should catch them with try-catch statement, and throw Platform::Exception instead - this way they'll be correctly marshaled back into the managed code.



来源:https://stackoverflow.com/questions/21274063/catching-unhandle-exception-in-c-cx

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