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. The Lounge
  3. And the prize for the most stupid error messages goes to....

And the prize for the most stupid error messages goes to....

Scheduled Pinned Locked Moved The Lounge
csharphelp
32 Posts 15 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.
  • OriginalGriffO OriginalGriff

    String.Empty isn't a constant: it's a static readonly value. Reference Source[^] As such, it's value could depend on the initialization sequence in theory. Anyway, "" is a lot clearer - and it's a constant! :laugh:

    Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

    Richard DeemingR Offline
    Richard DeemingR Offline
    Richard Deeming
    wrote on last edited by
    #9

    Yet another example of inaccurate code comments:

    Quote:[^]

    The Empty constant holds the empty string value.

    :doh:


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

    1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      String.Empty isn't a constant: it's a static readonly value. Reference Source[^] As such, it's value could depend on the initialization sequence in theory. Anyway, "" is a lot clearer - and it's a constant! :laugh:

      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

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

      So "" != String.Empty ? :laugh:

      Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.

      OriginalGriffO W 2 Replies Last reply
      0
      • F F ES Sitecore

        You should give your variables meaningful names.

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

        F-ES Sitecore wrote:

        You should give your variables meaningful names.

        I'm sure it was just an example but how do you know it's not meaningful anyway?

        Sin tack the any key okay

        F 1 Reply Last reply
        0
        • D David Radcliffe 0

          If it is set to readonly so can never change, doesn't that make it constant?

          K Offline
          K Offline
          kalberts
          wrote on last edited by
          #12

          Maybe we should have a modifier "SetOnceReadMany", to describe something that is not a "constant" in the sense of a literal, but will always return the same value when read. At least in a given run it returns the same value - not necessarily under varying conditions, such as moving your code to another operating system. The value is not modifiable (hence 'constant'), but depends on the OS (or some similar external condition.)

          L 1 Reply Last reply
          0
          • L Lost User

            So "" != String.Empty ? :laugh:

            Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.

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

            Nope, it's much better! :laugh:

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

            "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

            L M 2 Replies Last reply
            0
            • K kalberts

              Maybe we should have a modifier "SetOnceReadMany", to describe something that is not a "constant" in the sense of a literal, but will always return the same value when read. At least in a given run it returns the same value - not necessarily under varying conditions, such as moving your code to another operating system. The value is not modifiable (hence 'constant'), but depends on the OS (or some similar external condition.)

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

              Does not help. It still needs to store the string somewhere, even if the string is "" and once it does that, (1) what's stored at that location can be externally modified after compilation and/or during execution.

              Sin tack the any key okay

              K 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Nope, it's much better! :laugh:

                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

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

                Wait, what? You know you can't get high on diesel. Or are we still excited with that extra 40% per gallon by switching fuels?

                Sin tack the any key okay

                L 1 Reply Last reply
                0
                • L Lost User

                  F-ES Sitecore wrote:

                  You should give your variables meaningful names.

                  I'm sure it was just an example but how do you know it's not meaningful anyway?

                  Sin tack the any key okay

                  F Offline
                  F Offline
                  F ES Sitecore
                  wrote on last edited by
                  #16

                  It was only a joke :)

                  L 1 Reply Last reply
                  0
                  • F F ES Sitecore

                    It was only a joke :)

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

                    StyleCop: missing joke icon. :suss:

                    Sin tack the any key okay

                    K L 2 Replies Last reply
                    0
                    • L Lost User

                      Does not help. It still needs to store the string somewhere, even if the string is "" and once it does that, (1) what's stored at that location can be externally modified after compilation and/or during execution.

                      Sin tack the any key okay

                      K Offline
                      K Offline
                      kalberts
                      wrote on last edited by
                      #18

                      Sure, even if the value is burnt into a ROM, you can unsolder that ROM and put another one in place. So you can set Environment.NewLine to "xyzzy", if that satisfies you one way or the other. But that will neither change the newline convention in Windows, *nix or OSX. I've seen people, in classic K&R C, set up #define to give FALSE the value 1 and TRUE the value 0. And I've heard of people programming in Forth to set the value of 3 to 17 - in that language, the literal 3 is a symbol that just happens to initially have the value of e.g. the count of x-es in the string "xxx", but it can be redefined som something else. Aa a code obfuscation mechanism, it is of course great. I think that when you work in a given language, your task should be solved in that language, using the abstractions and concepts in that language. If it says that a value is constant, it IS constant for that problem solution. Just like you can go behind the compiler's back and change a contant value, you can also open an .exe or .dll file before it is run and change a "greater than" conditional jump to a "greater that or equal to" conditional jump. So the loop termination, while appearing to be constant at the source code level, is actually varying depending on which modification are made to the executable code file. If you start digging a huge hole in the ground underneath your house, your house will fall into it. You asked for it, you got it.

                      1 Reply Last reply
                      0
                      • L Lost User

                        StyleCop: missing joke icon. :suss:

                        Sin tack the any key okay

                        K Offline
                        K Offline
                        kalberts
                        wrote on last edited by
                        #19

                        Haha, that's a good one. While we are at it: How about truths, are they jokes? Like: Constants aint. Variables won't. (Maybe these are not absolute truths, even though you sometimes get that feeling.)

                        1 Reply Last reply
                        0
                        • L Lost User

                          Wait, what? You know you can't get high on diesel. Or are we still excited with that extra 40% per gallon by switching fuels?

                          Sin tack the any key okay

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

                          Lopatir wrote:

                          You know you can't get high on diesel.

                          Well, technically.. [Continental Diesel](http://www.continentaldiesel.com/typo3/index.php?id=2&L=1) :laugh:

                          Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.

                          1 Reply Last reply
                          0
                          • L Lost User

                            StyleCop: missing joke icon. :suss:

                            Sin tack the any key okay

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

                            Lopatir wrote:

                            missing joke icon

                            This is a form of natural selection.

                            Peter Wasser "The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts." - Bertrand Russell

                            1 Reply Last reply
                            0
                            • D David Radcliffe 0

                              Microsoft C#. I set a function parameter (string myVar = string.Empty) and got: Default parameter value for 'myVar' must be a compile-time constant I fail to see how anything could be more constant than string.Empty.... :laugh:

                              S Offline
                              S Offline
                              S Douglas
                              wrote on last edited by
                              #22

                              I raise you a SQL error.. [Error Message] TITLE: SQL Server Setup failure. ------------------------------ SQL Server Setup has encountered the following error: The given key was not present in the dictionary.. For help, click: ------------------------------ BUTTONS: OK ------------------------------ [/Error Message] In the end, it was not happy about an IP address in the cluster.


                              Common sense is admitting there is cause and effect and that you can exert some control over what you understand.

                              1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                Nope, it's much better! :laugh:

                                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                M Offline
                                M Offline
                                Mycroft Holmes
                                wrote on last edited by
                                #23

                                What!!! I've been extremely anal about using string.Empty instead of "" and you tell me it's the lesser option.

                                Never underestimate the power of human stupidity RAH

                                1 Reply Last reply
                                0
                                • F F ES Sitecore

                                  You should give your variables meaningful names.

                                  G Offline
                                  G Offline
                                  Gary Huck
                                  wrote on last edited by
                                  #24

                                  Tell him there's no functions in C#.

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    So "" != String.Empty ? :laugh:

                                    Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.

                                    W Offline
                                    W Offline
                                    Wearwolf
                                    wrote on last edited by
                                    #25

                                    Run this code

                                    if (ReferenceEquals(string.Empty, ""))
                                    {
                                    Console.WriteLine("\"\" is the same as String.Empty");
                                    }

                                    String.Empty and "" are likely to reference the same memory location so they are effectively the same (There's a name for this combining of string resources but I forget what it is). The problem with using String.Empty as a default value for a function parameter is that it's not a COMPILE time constant. The value stored in String.Empty is a reference to the string "" stored in memory and that reference doesn't get set until the program starts and the string "" gets loaded into memory. Because how can you have a reference to a memory location before the program has started? So basically this error message is 100% accurate. It wanted a compile time constant but was given a runtime constant and it said "That's not good enough, mate".

                                    L 1 Reply Last reply
                                    0
                                    • W Wearwolf

                                      Run this code

                                      if (ReferenceEquals(string.Empty, ""))
                                      {
                                      Console.WriteLine("\"\" is the same as String.Empty");
                                      }

                                      String.Empty and "" are likely to reference the same memory location so they are effectively the same (There's a name for this combining of string resources but I forget what it is). The problem with using String.Empty as a default value for a function parameter is that it's not a COMPILE time constant. The value stored in String.Empty is a reference to the string "" stored in memory and that reference doesn't get set until the program starts and the string "" gets loaded into memory. Because how can you have a reference to a memory location before the program has started? So basically this error message is 100% accurate. It wanted a compile time constant but was given a runtime constant and it said "That's not good enough, mate".

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

                                      I wasn't too serious :laugh: However, I think it would make sense if Microsoft actually allow parameters to have a default value of string.Empty instead of "". It's always been pushed as being a bad practice to have 'magic strings' in code.

                                      Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.

                                      1 Reply Last reply
                                      0
                                      • D David Radcliffe 0

                                        Microsoft C#. I set a function parameter (string myVar = string.Empty) and got: Default parameter value for 'myVar' must be a compile-time constant I fail to see how anything could be more constant than string.Empty.... :laugh:

                                        K Offline
                                        K Offline
                                        Kelly J Grant
                                        wrote on last edited by
                                        #27

                                        Many of you may not be old enough to remember this one. Dumbest error message I ever saw was from early Microsoft DOS: Keyboard not found. Press Enter to continue.

                                        J 1 Reply Last reply
                                        0
                                        • D David Radcliffe 0

                                          Microsoft C#. I set a function parameter (string myVar = string.Empty) and got: Default parameter value for 'myVar' must be a compile-time constant I fail to see how anything could be more constant than string.Empty.... :laugh:

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

                                          What about: Keyboard not found. Press any key to continue.

                                          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