Why is .NET exception not caught by try/catch block?

前端 未结 25 786
Happy的楠姐
Happy的楠姐 2020-12-04 19:24

I\'m working on a project using the ANTLR parser library for C#. I\'ve built a grammar to parse some text and it works well. However, when the parser comes across an illeg

25条回答
  •  南笙
    南笙 (楼主)
    2020-12-04 19:57

    To me, a catch (Exception) clause should've captured any exception whatsoever. Is there any reason why it wouldn't?

    The only possibility I can think of is that something else is catching it before you and handling it in a way that appears to be an uncaught exception (e.g. exiting the process).

    my try/catch block won't catch it and instead stops execution as an unhandled exception.

    You need to find what is causing the exit process. It might be something other than an unhandled exception. You might try using the native debugger with a breakpoint set on "{,,kernel32.dll}ExitProcess". Then use SOS to determine what managed code is calling exit process.

提交回复
热议问题