No more: "Object reference not set to an instance of an object."

Last post 11-09-2009 10:48 AM by hitchhiker999. 9 replies.

Sort Posts:

  • No more: "Object reference not set to an instance of an object."

    11-07-2009, 4:17 PM
    • Member
      point Member
    • hitchhiker999
    • Member since 08-26-2008, 12:30 PM
    • Posts 9

    I run a handful of large websites using .net - I love .net, I love C#

    In asp.net 4, please give us the name of the 'object reference' that's not set to an instance of an object :)

    I beg you, my life would change, as so would many others. If you're worried about some reflection cost, or whatever, at least make detailed errors an option.

    I appologise if this is already included, i couldn't search for it - the term is way too common!

    Frank.

  • Re: No more: "Object reference not set to an instance of an object."

    11-07-2009, 10:53 PM
    • All-Star
      91,126 point All-Star
    • SGWellens
    • Member since 01-02-2007, 4:27 PM
    • Twin Cities, MN
    • Posts 7,431
    • Moderator
      TrustedFriends-MVPs

    That's a great idea.  However I'm guessing there are technical reasons it's not possible.

    The line number of the exception is given and if you follow the practise of doing no more than one programming step per line of code, it's pretty obvious where the problem is.

     

    Steve Wellens

    My blog
  • Re: No more: "Object reference not set to an instance of an object."

    11-08-2009, 5:55 AM
    • All-Star
      36,316 point All-Star
    • rtpHarry
    • Member since 10-01-2006, 12:51 PM
    • Lincoln, England
    • Posts 5,847

    Yeah that is a pretty good idea. When I saw the headline I thought it was going to be something like "make asp.net never get null references".

    I wonder what the reason is that it hasn't been implemented....


  • Re: No more: "Object reference not set to an instance of an object."

    11-08-2009, 8:21 AM
    • Member
      point Member
    • hitchhiker999
    • Member since 08-26-2008, 12:30 PM
    • Posts 9

    SGWellens:
    However I'm guessing there are technical reasons it's not possible.

    Never assume something like that. This is computer software engineering - anything is (ofc) possible!

    Regarding line numbers, sometimes things fail within code you didn't write, code you dont even have access to.

    I can think of a hundred reasons why I'd want it. I'm willing to bet many others have their own list.

    Also, lurkers - you may want to digg this: http://digg.com/programming/ASP_NET_No_more_Object_reference_not_set_to_an_instance

  • Re: No more: "Object reference not set to an instance of an object."

    11-08-2009, 9:38 AM
    • All-Star
      91,126 point All-Star
    • SGWellens
    • Member since 01-02-2007, 4:27 PM
    • Twin Cities, MN
    • Posts 7,431
    • Moderator
      TrustedFriends-MVPs

    hitchhiker999:
    Never assume something like that. This is computer software engineering - anything is (ofc) possible!
     

     

    Sure anything is possible but at what cost?  The extra baggage could slow the runtime down to a crawl.

    If you write good code, it's not a problem.

    One logical step per line of code.  I would rather see the compiler modified to enforce this as a rule.  Then, many programming 'problems' would be solved.

    Steve Wellens

    My blog
  • Re: No more: "Object reference not set to an instance of an object."

    11-09-2009, 5:55 AM
    • Member
      point Member
    • hitchhiker999
    • Member since 08-26-2008, 12:30 PM
    • Posts 9

    SGWellens:
    The extra baggage could slow the runtime down to a crawl.

    On one of my sites we're receiving 2,000,000 page requests a day. My site is complex, elegant and is written by myself and a team of newbies (though >3 years experience) who have found solutions to all the problems we've faced (one logical step at a time!) I'm sure the amazingly intelligent and creative team at .NET can work out how to offset the minuscule cost involved, or even make it optional - as i suggested. I know I could.

    Our company has fought away many coders who said 'well obviously it cant be done, as it's not there yet', or.. 'well, it's a nice idea but..' - if it's a nice idea we made it happen. We're careful, we're clean, and we're efficient and fast - so is our code.

    I'm sure we could drag in another 200 people to say 'well, perhaps you should now place every line of code into a separate method, because you can see which method has failed' - no thanks. I'm sick of that, I don't use emacs, I've done this way too long to ever again look at a blank screen that says 'Operation may destabilize the runtime' also. I hate bland error messages, and a lot of us do.

    I use this stuff on the front line. My code is running on servers in clusters, far away from me, my debugger, my comfort zone, behind viciously hardened firewalls. It's precompiled, stripped of any debug conditions, it is running in production mode and I haven't seen a line number in a stack trace in years. If i switched the production sites into debug mode I'd cause chaos. There are countless browsers, countless systems, countless combinations of external networks interacting in countless way:

    And don't you think deploying .pdb files for line numbers has a performance hit in terms of storage space, lookups and deployment time for extensive networks!!!?

    I don't want to see 'Object not set to instance of a reference' - I want to see

    'xyz' not set to instance of a reference

    I don't think it's too much to ask, and I know there are people inside .NET who could make it happen with their eyes closed and their hands tied behind their backs.

    f

    btw: this debate aside, great article of yours: why sql updates fail - wish i'd read that a while back! :)



  • Re: No more: "Object reference not set to an instance of an object."

    11-09-2009, 9:35 AM
    • All-Star
      91,126 point All-Star
    • SGWellens
    • Member since 01-02-2007, 4:27 PM
    • Twin Cities, MN
    • Posts 7,431
    • Moderator
      TrustedFriends-MVPs

    Why do you think that feature isn't available now? 

    Steve Wellens

    My blog
  • Re: No more: "Object reference not set to an instance of an object."

    11-09-2009, 10:32 AM
    • Member
      point Member
    • hitchhiker999
    • Member since 08-26-2008, 12:30 PM
    • Posts 9

    Because it's not implemented yet.

    The advantages far out weigh any perceived implementation issues. It's daft to assume something can't be done because it's not yet done. There'd be no computer science / arts / music / creation-in-general if that was the case?!

    50$ says it's do-able. They're a hell of a team, and if it'll help the community it'll get done in one form or another.

  • Re: No more: "Object reference not set to an instance of an object."

    11-09-2009, 10:43 AM
    • All-Star
      91,126 point All-Star
    • SGWellens
    • Member since 01-02-2007, 4:27 PM
    • Twin Cities, MN
    • Posts 7,431
    • Moderator
      TrustedFriends-MVPs

    hitchhiker999:
    Because it's not implemented yet.
     

    Think harder.

    Steve Wellens

    My blog
  • Re: No more: "Object reference not set to an instance of an object."

    11-09-2009, 10:48 AM
    • Member
      point Member
    • hitchhiker999
    • Member since 08-26-2008, 12:30 PM
    • Posts 9

    Right.


Page 1 of 1 (10 items)