Catching Native Exceptions in CE w/ CF

  • Thread starter Thread starter Dave Hall
  • Start date Start date
D

Dave Hall

How can I catch a Native Exception in CE 4.1 w/ Compact Framework? It's
blowing my whole app out of the water. Even when I run it under the VS
debugger, it doesn't get caught by the debugger. It's happening just after a
background ThreadStart function terminates (that is, after the background
thread terminates), so I'm not sure where I can put a try block to catch it.
I don't think that putting it in main() would help because that's a
different thread, although I guess it wouldn't hurt to give it a try.

Besides not knowing where to put a try block, I'm not even sure if a Native
Exception is derived from the base Exception class and can be caught with a
standard try/catch construct, or if it has to be handled differently.
Everything in the problem thread is managed code written in C#. I'm pretty
sure there are no P/Invoke calls in the thread that's causing the trouble.
(I'll check and be sure tomorrow).

Any suggestions?

Thanks in advance,
Dave
 
You cannot catch Netive exceptions in managed environment. If the Dll in the
P/Invoke is yours, then you should catch the exception in you unmanaged dll.

Arsa
 
If it's not yours, the only option is to write a native shim dll that calls
the real DLL and has exception handling in it.
 
Back
Top