How to force CLR not to handle Exceptions from unmanaged code ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?RGFya3Jpc2Vy?=

    How to force CLR not to handle Exceptions from unmanaged code ?

    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;
    }
Working...