Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How does C# support and implement exception handling?

How does C# support and implement exception handling?

Scheduled Pinned Locked Moved C#
csharpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cateyes99
    wrote on last edited by
    #1

    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.

    P L 2 Replies Last reply
    0
    • C cateyes99

      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.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Liquid Nitrogen.

      C 1 Reply Last reply
      0
      • P PIEBALDconsult

        Liquid Nitrogen.

        C Offline
        C Offline
        cateyes99
        wrote on last edited by
        #3

        Don't get at all :doh:

        1 Reply Last reply
        0
        • C cateyes99

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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

          C 1 Reply Last reply
          0
          • L Lost User

            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

            C Offline
            C Offline
            cateyes99
            wrote on last edited by
            #5

            Thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups