|
-
January 25th, 2005, 05:36 PM
#1
Can't catch Access Violation!
Ok,
I've read through several threads on using SEH to catch exception that would normally not be caught by your standard try-catch blocks.
Using a basic setup, I cannot catch an Access Violation occuring in an ActiveX control that I am deleting.
Code:
static void my_translator(unsigned code, EXCEPTION_POINTERS *)
{
throw code;
}
// called in dialog constructor:
_set_se_translator(my_translator);
CMydialog::OnCloseConnection()
{
try
{
delete m_pWA;
}
catch(unsigned code)
{
AfxMessageBox("Testing: caught access violation");
}
}
Program crashes, my translator is never called. What am I missing?
-
January 26th, 2005, 09:19 AM
#2
-
January 26th, 2005, 09:51 AM
#3
Re: Can't catch Access Violation!
You can catch Structured Exceptions using catch(...).
Some conditions to be aware of...
1) The exception is occuring in another thread which is being started [your activeX call]. Exceptions are "thread-safe" but they are not propagated to other threads.
If you install a SE translator it must be done on a per thread bases. The SetUnhandledExceptionFilter(...) is a global handler.
2) Later versions of vc++ [8.0] the exception handling was changed such that you have to apply the /EHa switch to denote that you want to catch structured exceptions via a catch(...)
3) If you have faulty exception handling logic such as generating an exception out of a dtor of an local object being destructed while procesing a previous exception.
In the end you need to run your code under a debugger and find out why you are generating an exception in the ActiveX code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|