<p>I have unmanaged C++ calling a managed delegate via the function pointer provided by Marshal::GetFunctionPointerForDelegate.  This delegate has the potential to throw an exception.  I need to be able to properly handle this exception in my unmanaged C++ to ensure things like pointer cleanup, and potentially rethrow the exception up into more managed code.  The call stack is similar to this:</p>

<p>Managed Code -> Unmanaged C++ -> callback to Managed Code via delegate (exception can be thrown here).</p>

<p>Anyone have pointers for properly handling this situation so that the resources in unmanaged code can be cleaned up and a usable exception can be thrown out to the managed code which initiated the whole call stack?</p>

Catching from managed code with
```
```
try
{
  throw gcnew InvalidOperationException();
}
catch(InvalidOperationException^ e)
{
  // Process e
  throw;
}
```
```
And an
```
```
[assembly:RuntimeCompatibility(WrapNonExceptionThrows = true)];
```
```
on your assembly catches managed and unmanaged exceptions