What is the most common error in a .Net application?
-
I vote for the part where the user is given a chance to enter data. If a program is going to crash, that's most likely going to be the reason.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001My approach is to strike first.
Software Zen:
delete this;
-
That is something I do not understand. Why ToString() can't handle the "null" automatically? It must have a good reason.
TOMZ_KV
It's similar to an uninitialized pointer in C++. It's just the address of an object (which if null is an invalid address), nothing exists to implement the method.
-
In .net it is the classic "object reference not set to an instance of an object". Speaking of bugs, I started a new position back in June. This company (not an IT company) does an amazing job of testing. The first application I did here was coded in about 4 weeks by myself and a consultant. The company used the application in test for an entire month before we rolled it out. It has been live for six weeks now without one bug or code change required. This is the first time, I have accomplished this.
I didn't get any requirements for the signature
-
Last week we had a code delivery. We have been taught from the graduation days that ToString() without a null check is a bomb. Still we got it in a critical part . "Object reference not set" My vote goes for it.
modified on Monday, December 15, 2008 2:26 PM
You should program in Objective C where it is legal to invoke methods on nulls.
id v = nil;
NSString* valueAsString = [v description];modified on Monday, December 15, 2008 2:58 PM
-
You should program in Objective C where it is legal to invoke methods on nulls.
id v = nil;
NSString* valueAsString = [v description];modified on Monday, December 15, 2008 2:58 PM
Would his code have been any less broken?
-
You should program in Objective C where it is legal to invoke methods on nulls.
id v = nil;
NSString* valueAsString = [v description];modified on Monday, December 15, 2008 2:58 PM
ObjectiveC is a beast of its own... It's even legal to call method which don't exist! Who knows, a Forward or a Category might even intercept them?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
Would his code have been any less broken?
It Depends:).
-
ObjectiveC is a beast of its own... It's even legal to call method which don't exist! Who knows, a Forward or a Category might even intercept them?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
Super Lloyd wrote:
It's even legal to call method which don't exist!
Yes and this feature has its own strengths (and weaknesses).
-
jith - iii wrote:
If you can assign null to a string,
You're not assigning null to a string. You're setting a reference to a string to null (meaning it refers to nothing), not at all the same thing. You are forgetting that strings are reference types, not value types. Since the null is an invalid reference, there is nothing (no class instance or static object) which might implement ToString(), hence the null reference exception.
in C++, the target function actually gets called and so long as no reference is made to instance variables in that function, no null reference will occur due to the null 'this' (obviously, something else could be null). So, a somewhat common tactic is to test for "this == null" or "this != null".
-
That is something I do not understand. Why ToString() can't handle the "null" automatically? It must have a good reason.
TOMZ_KV
add a static extension method
string string.ToString(string target)
{
return (target ?? "").ToString();
}or simply code your ToString calls as:
(target ?? "").ToString()
-
In .net it is the classic "object reference not set to an instance of an object". Speaking of bugs, I started a new position back in June. This company (not an IT company) does an amazing job of testing. The first application I did here was coded in about 4 weeks by myself and a consultant. The company used the application in test for an entire month before we rolled it out. It has been live for six weeks now without one bug or code change required. This is the first time, I have accomplished this.
I didn't get any requirements for the signature
334,000 google search results for the error message(with quotes). It surely is the most popular
C isn't that hard: void (*(*f[])())() defines f as an array of unspecified size, of pointers to functions that return pointers to functions that return void "Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live." - Martin Golding
-
jith - iii wrote:
If you can assign null to a string,
You're not assigning null to a string. You're setting a reference to a string to null (meaning it refers to nothing), not at all the same thing. You are forgetting that strings are reference types, not value types. Since the null is an invalid reference, there is nothing (no class instance or static object) which might implement ToString(), hence the null reference exception.
well,grammer may be wrong,but I meant the same. It will instantly give error if you try to set null to an integer,right? why double standard to string where you can set it to nothing but not otherwise? :) (Just consider this as an emotional outburst. I don't really want to excuse people forgetting a null check)
-
add a static extension method
string string.ToString(string target)
{
return (target ?? "").ToString();
}or simply code your ToString calls as:
(target ?? "").ToString()
-
In .net it is the classic "object reference not set to an instance of an object". Speaking of bugs, I started a new position back in June. This company (not an IT company) does an amazing job of testing. The first application I did here was coded in about 4 weeks by myself and a consultant. The company used the application in test for an entire month before we rolled it out. It has been live for six weeks now without one bug or code change required. This is the first time, I have accomplished this.
I didn't get any requirements for the signature
ToddHileHoffer wrote:
It has been live for six weeks now without one bug or code change required
You do realize no one is using it, don't you?
Bar fomos edo pariyart gedeem, agreo eo dranem abal edyero eyrem kalm kareore
-
ToddHileHoffer wrote:
It has been live for six weeks now without one bug or code change required
You do realize no one is using it, don't you?
Bar fomos edo pariyart gedeem, agreo eo dranem abal edyero eyrem kalm kareore
MidwestLimey wrote:
You do realize no one is using it, don't you?
That is what I thought at first. After the second day of it being in production I had to check the database to see what was up. I hadn't gotten any emails from the error handler. I thought either the error handler is busted or they were not using it.
I didn't get any requirements for the signature
-
ObjectiveC is a beast of its own... It's even legal to call method which don't exist! Who knows, a Forward or a Category might even intercept them?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
Super Lloyd wrote:
ObjectiveC is a beast of its own... It's even legal to call method which don't exist!
ObjectiveC is an attempt to turn C into SmallTalk.
-
You should program in Objective C where it is legal to invoke methods on nulls.
id v = nil;
NSString* valueAsString = [v description];modified on Monday, December 15, 2008 2:58 PM
Rama Krishna Vavilala wrote:
in Objective C where it is legal to invoke methods on nulls
It is legal in C++ too, and in some weird cases can be even safe :)
-
In .net it is the classic "object reference not set to an instance of an object". Speaking of bugs, I started a new position back in June. This company (not an IT company) does an amazing job of testing. The first application I did here was coded in about 4 weeks by myself and a consultant. The company used the application in test for an entire month before we rolled it out. It has been live for six weeks now without one bug or code change required. This is the first time, I have accomplished this.
I didn't get any requirements for the signature
ToddHileHoffer wrote:
The company used the application in test for an entire month before we rolled it out. It has been live for six weeks now without one bug or code change required.
If the pay is decent and they don't require you to become a manager to get a raise, you have probably died and gone to Paradise.
Jon Smith & Wesson: The original point and click interface
-
ToddHileHoffer wrote:
The company used the application in test for an entire month before we rolled it out. It has been live for six weeks now without one bug or code change required.
If the pay is decent and they don't require you to become a manager to get a raise, you have probably died and gone to Paradise.
Jon Smith & Wesson: The original point and click interface
Oakman wrote:
If the pay is decent and they don't require you to become a manager to get a raise, you have probably died and gone to Paradise.
It is not paradise, but it is a damn good job. I feel very lucky.
I didn't get any requirements for the signature
-
Last week we had a code delivery. We have been taught from the graduation days that ToString() without a null check is a bomb. Still we got it in a critical part . "Object reference not set" My vote goes for it.
modified on Monday, December 15, 2008 2:26 PM
Turning on the computer. At least, today it is for me. I'm having total brain fade, can hardly remember how to type, never mind code.:)
Henry Minute Never read Medical books. You could die of a misprint. - Mark Twain