Created
June 6, 2019 15:38
-
-
Save Lovesan/afb2847962c8873ec4011f0ea3ac20d4 to your computer and use it in GitHub Desktop.
Example .NET library which internally throws an exception and catches it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cl.exe /nologo /clr /Od /MD /EHac /LD /Fe:sehlib.dll sehlib_net.cxx | |
using namespace System; | |
#include <iostream> | |
void throws_fn() | |
{ | |
std::cerr << ".NET throws exception" << std::endl; | |
throw gcnew Exception(); | |
} | |
extern "C" __declspec(dllexport) void catches_fn() | |
{ | |
try | |
{ | |
throws_fn(); | |
} | |
catch(Exception^ ex) | |
{ | |
std::cerr << ".NET catches exception" << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment