I have a C# application which calls a function in a C++ dll. This function can throw various exceptions which inherits std::exception
. I currently catch these exceptions like this:
try
{
//Call to C++ dll
}
catch (System.Exception exception)
{
//Some error handling code
}
My first question is will this code catch all std::exception
? My second question is how can I retrieve the std::exception::what
string, if I examine exception.Message
I only get "External component has thrown an exception".
EDIT: The function in question is in a non managed C++ dll, and imported like this in the C# class:
[DllImport("SomeDLL.dll")]
public extern static void SomeFunction();