How does C# support and implement exception handling?
-
Hi, we know if there is try-catch in place for an exception, it'll be caught and handled then when the exception occurs. But how this magic happens? How C#/compiler implements this exception handling feature at low level? Thanks.
Liquid Nitrogen.
-
Liquid Nitrogen.
-
Hi, we know if there is try-catch in place for an exception, it'll be caught and handled then when the exception occurs. But how this magic happens? How C#/compiler implements this exception handling feature at low level? Thanks.
Do you really want to know? Have you read ECMA-335? Anyway, MSIL contains high level constructs for things such as exception handling, and the JIT compiler and runtime do the actual magic. What kind of magic that is, well, I could find that out for you, but you could also mess around with some exception handling code and look at the disassembly window. The C# compiler doesn't really have anything to do with the actual implementation of the exception mechanisms, in MSIL it's still a .try block and some catch/finally/filter (can choose to have the catch ignore the exception)/fault (executes when an exception was thrown but does not catch it) blocks, no stack-walking code is generated by the C# compiler Note: I apologize in advance for all mistakes I've made in this post
-
Do you really want to know? Have you read ECMA-335? Anyway, MSIL contains high level constructs for things such as exception handling, and the JIT compiler and runtime do the actual magic. What kind of magic that is, well, I could find that out for you, but you could also mess around with some exception handling code and look at the disassembly window. The C# compiler doesn't really have anything to do with the actual implementation of the exception mechanisms, in MSIL it's still a .try block and some catch/finally/filter (can choose to have the catch ignore the exception)/fault (executes when an exception was thrown but does not catch it) blocks, no stack-walking code is generated by the C# compiler Note: I apologize in advance for all mistakes I've made in this post