G
Guest
The following managed C++ function is called from an unmanaged C++ DLL:
double Divide( double num, double denom )
{
if( denom == 0.0 )
throw new std::exception( "divide by zero" );
return num / denom;
}
The caller calls the function within a C++ try-catch block, with the following two catch blocks:
catch( std::exception& ex ) { // do something }
catch( ... ) { // do something else }
If my managed code is running in the DefaultDomain and throws the exception, then the first catch block is executed. However, if the code is running in another appdomain, then the second catch block is executed!
I cannot find anything documented on MSDN or the Web that explains this behavior. I also have not found any workaround (I can use SEH primitives directly in my unmanaged code to catch or "translate" the exception, but what I really want is access to the exception message).
I am running Visual Studio .NET 2003 on Windows XP.
My managed assembly is loaded first into the non-default domain (another assembly loads it manually prior to any calls from unmanaged code). It is compiled with the /clr:initialAppDomain flag, because I need to make sure unmanaged calls are executed in this domain.
double Divide( double num, double denom )
{
if( denom == 0.0 )
throw new std::exception( "divide by zero" );
return num / denom;
}
The caller calls the function within a C++ try-catch block, with the following two catch blocks:
catch( std::exception& ex ) { // do something }
catch( ... ) { // do something else }
If my managed code is running in the DefaultDomain and throws the exception, then the first catch block is executed. However, if the code is running in another appdomain, then the second catch block is executed!
I cannot find anything documented on MSDN or the Web that explains this behavior. I also have not found any workaround (I can use SEH primitives directly in my unmanaged code to catch or "translate" the exception, but what I really want is access to the exception message).
I am running Visual Studio .NET 2003 on Windows XP.
My managed assembly is loaded first into the non-default domain (another assembly loads it manually prior to any calls from unmanaged code). It is compiled with the /clr:initialAppDomain flag, because I need to make sure unmanaged calls are executed in this domain.