Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,808,556 Members 42,296 Now Online
XDA Developers Android and Mobile Development Forum

[Q] How can Windows Phone 8 handle AccessViolationException?

Tip us?
(Last edited by punwinger; 14th February 2014 at 06:07 AM.)
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Feb 2014
Default [Q] How can Windows Phone 8 handle AccessViolationException?

There are many C++/CX codes in my Windows Phone 8 app so there might be many dangling pointers access which will cause AccessViolationException. Actually I know that __try & __except can catch them but I hope that my app can get notified like some callback function can get called while AccessViolationException raised that it's NOT surrounding by __try __except.
And I have tried Application.UnhandledException in C# code and ::SetUnhandledExceptionFilter(which is private API and I somehow successfully invoke it) but still failed to get called.
So is there any way to get notified while AccessViolationException is raised?
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Feb 2014
In case somebody has the same problem, I solve my problem by using _set_se_translator, a crt API
Recognized Developer
Thanks Meter 2,699
Posts: 5,681
Join Date: Jan 2011
Location: Seattle
Ooh, details on that would be good (OK, I should just go read the docs...) but thanks for posting the solution! C++/CX has way too many modes of memory management; it's pretty easy to get it wrong if you try doing anything even vaguely outside the standard use cases. (Example: Do not malloc an array of Platform::String and then assign to it. Any non-nulls in the array (leftover data from prior allocations) will be treated as though they are valid strings that you are assigning over, which means the "old string's" reference count will be decremented, which may lead to memory corruption. Using calloc instead works, by the way, though it's still kind of a hack.) Anyhow, debugging that stuff is annoying, especially since you can only debug native *or* managed, not both.
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.

Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes