Im calling a function in a 3rd party dll. Somewhere down the line it hits an access violation (0xC0000005).

I wrapped the call in a try/catch but it never catches and the runtime pops up the old Unhandled Exception.

This call is several calls deep in my code so I wrapped each parent with try/catch.
Doing this, the exception gets caught 3 calls up, skipping 3 try/catch blocks.

This is just wrong.

Any ideas on how to make this catch when it's supposed to?


8 Years
Discussion Span
Last Post by SVR

Complain to your vendor. If their DLL is broken they are obligated to fix it.

Otherwise, read on:

For some oddball reason the C++ design doesn't think that system exceptions belong as part of the exception-handling structure. (Nevermind that every computer hardware has access interrupts, div-by-zero interrupts, etc.)

You need to either:

  1. Compile using VC++ using exception extentions
  2. Roll your own SEH block

If you go for number 2, a good place to start is
A Crash Course on the Depths of Win32™ Structured Exception Handling

You will also need the reference.

Good luck!


Thank you.

It turns out (after trying the various different exception handling techniques) that the exception was being thrown from another part of the code.

The dll calls the suspect function internally so I assumed it was from my call.

There's that word ...

Thanks again!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.