Click here to Skip to main content
15,887,027 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Who wrote this code? Pin
Marc Clifton13-May-18 12:03
mvaMarc Clifton13-May-18 12:03 
GeneralMystery of the Missing (foreign) Keys Pin
Rob Grainger2-May-18 5:43
Rob Grainger2-May-18 5:43 
GeneralRe: Mystery of the Missing (foreign) Keys Pin
Eddy Vluggen2-May-18 7:48
professionalEddy Vluggen2-May-18 7:48 
GeneralRe: Mystery of the Missing (foreign) Keys Pin
Keith Barrow4-May-18 4:42
professionalKeith Barrow4-May-18 4:42 
GeneralRe: Mystery of the Missing (foreign) Keys Pin
Nathan Minier7-May-18 2:16
professionalNathan Minier7-May-18 2:16 
GeneralRe: Mystery of the Missing (foreign) Keys Pin
jeron12-May-18 8:11
jeron12-May-18 8:11 
GeneralRe: Mystery of the Missing (foreign) Keys Pin
PIEBALDconsult10-May-18 3:11
mvePIEBALDconsult10-May-18 3:11 
GeneralC# Recipe for uncatchable exception Pin
Super Lloyd30-Apr-18 17:38
Super Lloyd30-Apr-18 17:38 
I had the following code in my app. Turns out you just CAN'T debug that code. At least with Visual Studio 2017,
It will crash your process instantly and you will be left without any clue as to what was wrong!!
Gotta report that to Microsoft..
Meanwhile, behold the evilest safe C# code that can be!
C#
class Program
{
    static void Main(string[] args)
    {
        try { Fail(); }
        catch (Exception ex) { Log(ex); }
    }
    static void Fail()
    {
        throw new NotSupportedException("You Fool!");
    }
    static void Log(Exception ex)
    {
        var sb = new StringBuilder();
        Log(ex);
        Console.WriteLine($"Problem: {sb}");
    }
}

[EDIT] To clarify, of course this code is buggy, it's a bug repro.
But most remarkably the program just crash without hint from Visual Studio. Even if you ask Visual Studio to stop on StackOverflowException, it won't!

[EDIT2] Setting breakpoints is not the problem...
But why would you put a breakpoint there if you didn't know the bug was there in the first place?
FYI it's about 1 month of work before this bug came to light!
A new .NET Serializer
All in one Menu-Ribbon Bar
Taking over the world since 1371!


modified 1-May-18 7:39am.

GeneralRe: C# Recipe for uncatchable exception Pin
virang_2130-Apr-18 18:25
virang_2130-Apr-18 18:25 
GeneralRe: C# Recipe for uncatchable exception Pin
Super Lloyd30-Apr-18 18:28
Super Lloyd30-Apr-18 18:28 
GeneralRe: C# Recipe for uncatchable exception Pin
Pete O'Hanlon30-Apr-18 19:40
mvePete O'Hanlon30-Apr-18 19:40 
GeneralRe: C# Recipe for uncatchable exception Pin
Super Lloyd1-May-18 1:43
Super Lloyd1-May-18 1:43 
GeneralRe: C# Recipe for uncatchable exception PinPopular
CodeWraith30-Apr-18 20:12
CodeWraith30-Apr-18 20:12 
GeneralRe: C# Recipe for uncatchable exception Pin
Super Lloyd30-Apr-18 20:20
Super Lloyd30-Apr-18 20:20 
GeneralRe: C# Recipe for uncatchable exception Pin
Paulo Zemek1-May-18 13:24
mvaPaulo Zemek1-May-18 13:24 
GeneralRe: C# Recipe for uncatchable exception Pin
raddevus1-May-18 2:36
mvaraddevus1-May-18 2:36 
GeneralRe: C# Recipe for uncatchable exception Pin
CodeWraith1-May-18 8:55
CodeWraith1-May-18 8:55 
GeneralRe: C# Recipe for uncatchable exception Pin
User 110609791-May-18 9:01
User 110609791-May-18 9:01 
GeneralRe: C# Recipe for uncatchable exception Pin
Kornfeld Eliyahu Peter30-Apr-18 20:34
professionalKornfeld Eliyahu Peter30-Apr-18 20:34 
QuestionRe: C# Recipe for uncatchable exception Pin
Super Lloyd1-May-18 1:21
Super Lloyd1-May-18 1:21 
GeneralRe: C# Recipe for uncatchable exception Pin
Kornfeld Eliyahu Peter1-May-18 1:27
professionalKornfeld Eliyahu Peter1-May-18 1:27 
AnswerRe: C# Recipe for uncatchable exception Pin
Eddy Vluggen1-May-18 1:45
professionalEddy Vluggen1-May-18 1:45 
GeneralRe: C# Recipe for uncatchable exception Pin
Super Lloyd1-May-18 4:16
Super Lloyd1-May-18 4:16 
GeneralRe: C# Recipe for uncatchable exception Pin
Eddy Vluggen1-May-18 5:15
professionalEddy Vluggen1-May-18 5:15 
GeneralRe: C# Recipe for uncatchable exception Pin
Super Lloyd1-May-18 13:47
Super Lloyd1-May-18 13:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.