Get Error Number in C#
-
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.”
-
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
-
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.
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.
-
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.
-
I THINK IT IS APPLY FOR ALL PROGRAMS IN MY COMPUTER. AM I RIGHT?
If you can think then I Can.
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.
-
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.
-
I THINK IT IS APPLY FOR ALL PROGRAMS IN MY COMPUTER. AM I RIGHT?
If you can think then I Can.
-
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.
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...
}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) -
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.
-
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 :)