Win32 SEH异常也可以作为.NET异常捕获。在下面的代码中,托管函数(main)调用本机函数(f),该函数抛出SEH exception exception_INT_DIVIDE_BY_ZERO。大体上,这个异常是在处理System::ExceptionA类型异常的catch块中捕获的。

//ExceptionHandling2.cpp//compile with "cl /clr ExceptionHandling2.cpp"//As I will discuss later, #pargma managed is not recommended; it is only//used to show exceptions thrown across managed / unmanaged boundaries//without using two source files #pragma unmanaged int f() {

#pragma managed int main() {

catch(System::ExceptionA ex) {

System::Console::WriteLine(ex
->GetType()->FullName);

标签: none

添加新评论