Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

when I debug the application , if there is any error occurs exception block get executed. I need to find the line where i got the error.(I need to go previous line from exception block)


Is there any way?



Thanks & Regards,
Pal.
Posted
Comments
Argonia 8-May-12 7:57am    
Are you sure that you have a block catching this error ? Maybe its other kind of error. Paste the error and the code if its possible. But the old fashion way of catching an error is with debug and break points in the right locations. You can try to look at the call stack if you are writing in Visual Studio

1 solution

Pal. The standard way to figure this out is to actually evaluate what the Exception is telling you. In debug builds, it will contain a reliable StackTrace, and if you print it out with .ToString() you get the details of exactly which line failed. So, in your Exception handler, add the following code (assuming that you've called your Exception variable ex).
C#
try
{
 ... exception is thrown here.
}
catch (Exception ex)
{
  Debug.WriteLine(ex.ToString());
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900