I have managed code in C# calling unmanaged code from a DLL written in C++.
Every time an Exception is thrown by unmanaged code, this exception is
handled by C# directly.
How to force to handle the exception by the DLL itself, instead of C# ?
example attached below.
//C# code
[DllImport("some .dll")]
public static extern int A();
static int Main()
{
try {
A();
} catch {
// handle exception by managed code
}
}
// C++ code
extern "C" __declspec(dlle xport) int A();
int B(void);
int A()
{
try {
B();
} catch (...) {
// handle exception by unamanged code
// how to handle the exeption here ???
}
}
int B()
{
// throw some exception
throw;
}
Every time an Exception is thrown by unmanaged code, this exception is
handled by C# directly.
How to force to handle the exception by the DLL itself, instead of C# ?
example attached below.
//C# code
[DllImport("some .dll")]
public static extern int A();
static int Main()
{
try {
A();
} catch {
// handle exception by managed code
}
}
// C++ code
extern "C" __declspec(dlle xport) int A();
int B(void);
int A()
{
try {
B();
} catch (...) {
// handle exception by unamanged code
// how to handle the exeption here ???
}
}
int B()
{
// throw some exception
throw;
}