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. Get Error Number in C#

Get Error Number in C#

Scheduled Pinned Locked Moved C#
csharphelpquestion
16 Posts 7 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.
  • L Lost User

    Hi All, How can i get the error number in c#.

    If you can think then I Can.

    H Offline
    H Offline
    Henry Minute
    wrote on last edited by
    #3

    Which error do you want the number for? I've had most of them in my time, so I might be able to let you have it.

    Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

    OriginalGriffO L 2 Replies Last reply
    0
    • H Henry Minute

      Which error do you want the number for? I've had most of them in my time, so I might be able to let you have it.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #4

      Just give him a copy (they aren't DRM after all). You might need it again - I know I will need mine! :laugh:

      No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • L Lost User

        Hi All, How can i get the error number in c#.

        If you can think then I Can.

        0 Offline
        0 Offline
        0x3c0
        wrote on last edited by
        #5

        Have you tried looking at the GetLastError API method? I think that there's a managed wrapper around that which may help (Marshal.GetLastWin32Error I think)

        Between the idea And the reality Between the motion And the act Falls the Shadow

        L 1 Reply Last reply
        0
        • D DaveyM69

          Error number of what?

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
          Why are you using VB6? Do you hate yourself? (Christian Graus)

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

          IN VB WE CAN CHECK ERROR NO. BY USING ON ERROR GOTO ERR ERR: MSGBOX (ERR.NUMBER) NOW HOW CAN IT POSSIBLE IN C#

          If you can think then I Can.

          C D 2 Replies Last reply
          0
          • H Henry Minute

            Which error do you want the number for? I've had most of them in my time, so I might be able to let you have it.

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

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

            MY REPLY IS POSTED PLEASE CHECK

            If you can think then I Can.

            C 1 Reply Last reply
            0
            • 0 0x3c0

              Have you tried looking at the GetLastError API method? I think that there's a managed wrapper around that which may help (Marshal.GetLastWin32Error I think)

              Between the idea And the reality Between the motion And the act Falls the Shadow

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

              I THINK IT IS APPLY FOR ALL PROGRAMS IN MY COMPUTER. AM I RIGHT?

              If you can think then I Can.

              C L 2 Replies Last reply
              0
              • L Lost User

                IN VB WE CAN CHECK ERROR NO. BY USING ON ERROR GOTO ERR ERR: MSGBOX (ERR.NUMBER) NOW HOW CAN IT POSSIBLE IN C#

                If you can think then I Can.

                C Offline
                C Offline
                Colin Angus Mackay
                wrote on last edited by
                #9

                STOP SHOUTING - It is rude!

                User group: Scottish Developers Blog: Can Open... Worms? Everywhere! Quote: Man who stand on hill with mouth open wait long time for roast duck to drop in.

                L 1 Reply Last reply
                0
                • L Lost User

                  MY REPLY IS POSTED PLEASE CHECK

                  If you can think then I Can.

                  C Offline
                  C Offline
                  Colin Angus Mackay
                  wrote on last edited by
                  #10

                  THERE'S NO NEED TO SHOUT - WE CAN HEAR YOU FINE. It is also rude to use all caps.

                  User group: Scottish Developers Blog: Can Open... Worms? Everywhere! Quote: Man who stand on hill with mouth open wait long time for roast duck to drop in.

                  1 Reply Last reply
                  0
                  • L Lost User

                    I THINK IT IS APPLY FOR ALL PROGRAMS IN MY COMPUTER. AM I RIGHT?

                    If you can think then I Can.

                    C Offline
                    C Offline
                    Colin Angus Mackay
                    wrote on last edited by
                    #11

                    eg_Anubhava wrote:

                    AM I RIGHT?

                    I DON'T KNOW. I CAN'T THINK OVER THE SOUND OF HOW LOUD YOU ARE SHOUTING.

                    User group: Scottish Developers Blog: Can Open... Worms? Everywhere! Quote: Man who stand on hill with mouth open wait long time for roast duck to drop in.

                    1 Reply Last reply
                    0
                    • C Colin Angus Mackay

                      STOP SHOUTING - It is rude!

                      User group: Scottish Developers Blog: Can Open... Worms? Everywhere! Quote: Man who stand on hill with mouth open wait long time for roast duck to drop in.

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

                      ok colin

                      If you can think then I Can.

                      1 Reply Last reply
                      0
                      • L Lost User

                        I THINK IT IS APPLY FOR ALL PROGRAMS IN MY COMPUTER. AM I RIGHT?

                        If you can think then I Can.

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

                        Even a quick google would have shown that to be untrue. If you google it, the first thing you see is: GetLastError Function (Windows) Retrieves the calling thread's last-error code value.

                        L 1 Reply Last reply
                        0
                        • L Lost User

                          IN VB WE CAN CHECK ERROR NO. BY USING ON ERROR GOTO ERR ERR: MSGBOX (ERR.NUMBER) NOW HOW CAN IT POSSIBLE IN C#

                          If you can think then I Can.

                          D Offline
                          D Offline
                          DaveyM69
                          wrote on last edited by
                          #14

                          In C# we do this by putting the code below where the On Error Goto would be inside a try block. The Err label is replaced by catch block(s). In addition we have an optional finally block that is run after either have completed:

                          try
                          {
                          // code that may throw an exception
                          }
                          catch(Exception ex)
                          {
                          // an exception is now in ex so you can examine this to get details,
                          // show detailed MessageBox etc...
                          }
                          finally
                          {
                          // this will run regardless of whether an exception was thrown or not.
                          // useful to close/dispose of objects etc...
                          }

                          More details here[^].

                          Dave
                          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
                          Why are you using VB6? Do you hate yourself? (Christian Graus)

                          1 Reply Last reply
                          0
                          • L Lost User

                            Even a quick google would have shown that to be untrue. If you google it, the first thing you see is: GetLastError Function (Windows) Retrieves the calling thread's last-error code value.

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

                            Sorry But Please Explain It to finding Err.Number.

                            If you can think then I Can.

                            N 1 Reply Last reply
                            0
                            • L Lost User

                              Sorry But Please Explain It to finding Err.Number.

                              If you can think then I Can.

                              N Offline
                              N Offline
                              Narendra Reddy Vajrala
                              wrote on last edited by
                              #16

                              Hey Anubhava... did you got the solution to find error number in c#.net??? i have the same requirement i tried so much but i did not found solution :( please pass solution if you got tnx in advance :)

                              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