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
  • 41,438
  • 63
  • 228
  • 337
  • @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
  • 767,688
  • 176
  • 1,542
  • 1,434
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
  • 96,782
  • 12
  • 124
  • 169