"Debugging Nightmares: Got C# Exception Handling Tricks to Share?"

f3zee123321

New member
Joined
Nov 16, 2017
Messages
3
Reaction score
0
"Yo fellow devs, anyone else out there have a love-hate relationship with C# exception handling? I'm looking for some fresh tricks to tackle those gnarly errors that always seem to pop up at 2 AM. Share your go-to techniques for elegantly handling exceptions in C#!"
 

dzjuba_m

Member
Joined
Jan 1, 2011
Messages
5
Reaction score
0
Y'all, I've been there too. One trick I swear by is using a global exception handler in your app, so you can catch any unhandled exceptions and log them for debugging later. Helps a ton when you're in a tight spot.
 

Fockers

New member
Joined
Feb 13, 2011
Messages
2
Reaction score
0
"Hey guys, I'm no expert but I've found that using try-catch blocks with Debug.WriteLine() can be a lifesaver when debugging C#. Saves so much time when you're trying to track down those pesky null reference exceptions. Anyone else use this trick?"
 

*VLAD*

New member
Joined
Jun 8, 2011
Messages
2
Reaction score
0
"yup, one trick I've found super helpful is using try-catch blocks, but I've also found that sometimes it's better to use a finally block to make sure resources get released, no matter what happens"
 
Joined
Apr 15, 2011
Messages
3
Reaction score
0
"Yea, been there, done that - try using Visual Studio's built-in exception handling feature to catch and analyze exceptions, it's a total lifesaver. Also, use a logger like Serilog to log exceptions and errors, makes it easier to track them down later."
 

Arseny1

New member
Joined
Jan 19, 2017
Messages
4
Reaction score
0
"Who else is still using Visual Studio's debug console to catch and log exceptions? Been a lifesaver for me when Visual Studio just won't cooperate. Anyone use NLog for logging and error tracking?"
 

tabula

New member
Joined
Apr 12, 2006
Messages
3
Reaction score
0
"Lol yeah, C# can be a real pain to debug sometimes. I've had good luck using the 'try-catch' block with 'Debugger.Break' to pause execution when an exception occurs, makes it easier to inspect the state of the program. Anyone else use this trick?"
 
Top