1

Let's say we have C# called by an unmanaged C++ application. The caller's code is unavailable.

public void MethodCalledByUnmanagedCode()
{
try
{
   DoWork()
}
catch {}//assume we swallow exception, no logging or anything
}

In this case, is there any way possible for any exception to bubble up to unmanaged C++ in any circumstance?

P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
  • @pst - there are reports of exceptions bubbling up in exactly this circumstance. I want to know how that is possible. Note that there is a logging mechanism that will be plugged in here. – P.Brian.Mackey Jun 23 '12 at 18:21

2 Answers2

4

Your code could raise a ThreadAbortException.

ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block.

Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
2

There are also exceptions that will never make to your exception handler like StackOverflowException in normal circumstances.

See details C# catch a stack overflow exception.

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179