Click here to Skip to main content
15,881,248 members
Home / Discussions / C#
   

C#

 
GeneralRe: Will calling a new method/property work if called on a "base" abstract object Pin
pr1mem0ver10-Apr-22 6:10
pr1mem0ver10-Apr-22 6:10 
QuestionProblem with BackgroundWorker component? Pin
Member 140558797-Apr-22 1:23
Member 140558797-Apr-22 1:23 
AnswerRe: Problem with BackgroundWorker component? Pin
Richard MacCutchan7-Apr-22 1:41
mveRichard MacCutchan7-Apr-22 1:41 
AnswerRe: Problem with BackgroundWorker component? Pin
Luc Pattyn7-Apr-22 6:30
sitebuilderLuc Pattyn7-Apr-22 6:30 
AnswerRe: Problem with BackgroundWorker component? Pin
Gerry Schmitz7-Apr-22 6:30
mveGerry Schmitz7-Apr-22 6:30 
QuestionC# Exception: An object reference does not point to an instance of an objec Pin
Member 155831391-Apr-22 0:29
Member 155831391-Apr-22 0:29 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Richard Deeming1-Apr-22 0:51
mveRichard Deeming1-Apr-22 0:51 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
OriginalGriff1-Apr-22 0:53
mveOriginalGriff1-Apr-22 0:53 
As I said last time you asked this:
Quote:
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself.

Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it contains null - which means that there is no instance of a class in the variable.
It's a bit like a pocket: you have a pocket in your shirt, which you use to hold a pen. If you reach into the pocket and find there isn't a pen there, you can't sign your name on a piece of paper - and you will get very funny looks if you try! The empty pocket is giving you a null value (no pen here!) so you can't do anything that you would normally do once you retrieved your pen. Why is it empty? That's the question - it may be that you forgot to pick up your pen when you left the house this morning, or possibly you left the pen in the pocket of yesterday's shirt when you took it off last night.

We can't tell, because we weren't there, and even more importantly, we can't even see your shirt, much less what is in the pocket!

Back to computers, and you have done the same thing, somehow - and we can't see your code, much less run it and find out what contains null when it shouldn't.
But you can - and Visual Studio will help you here. Run your program in the debugger and when it fails, it will show you the line it found the problem on. You can then start looking at the various parts of it to see what value is null and start looking back through your code to find out why. So put a breakpoint at the beginning of the method containing the error line, and run your program from the start again. This time, the debugger will stop before the error, and let you examine what is going on by stepping through the code looking at your values.

But we can't do that - we don't have your code, we don't know how to use it if we did have it, we don't have your data. So try it - and see how much information you can find out!


Use the debugger. We can't do that for you!
"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
AntiTwitter: @DalekDave is now a follower!

AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Richard MacCutchan1-Apr-22 1:07
mveRichard MacCutchan1-Apr-22 1:07 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Dave Kreskowiak1-Apr-22 2:12
mveDave Kreskowiak1-Apr-22 2:12 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Gary R. Wheeler2-Apr-22 3:21
Gary R. Wheeler2-Apr-22 3:21 
GeneralRe: C# Exception: An object reference does not point to an instance of an objec Pin
Pete O'Hanlon5-Apr-22 4:03
mvePete O'Hanlon5-Apr-22 4:03 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Raphael Adeniji10-Apr-22 14:20
Raphael Adeniji10-Apr-22 14:20 
AnswerRe: C# Exception: An object reference does not point to an instance of an objec Pin
Raphael Adeniji12-Apr-22 3:36
Raphael Adeniji12-Apr-22 3:36 
QuestionAccess Android Tablet from C# Pin
Kevin Marois30-Mar-22 18:23
professionalKevin Marois30-Mar-22 18:23 
AnswerRe: Access Android Tablet from C# Pin
Richard MacCutchan30-Mar-22 22:30
mveRichard MacCutchan30-Mar-22 22:30 
GeneralRe: Access Android Tablet from C# Pin
Kevin Marois31-Mar-22 6:15
professionalKevin Marois31-Mar-22 6:15 
GeneralRe: Access Android Tablet from C# Pin
Richard MacCutchan31-Mar-22 6:19
mveRichard MacCutchan31-Mar-22 6:19 
AnswerRe: Access Android Tablet from C# Pin
OriginalGriff31-Mar-22 3:09
mveOriginalGriff31-Mar-22 3:09 
GeneralRe: Access Android Tablet from C# Pin
Kevin Marois31-Mar-22 6:16
professionalKevin Marois31-Mar-22 6:16 
GeneralRe: Access Android Tablet from C# Pin
Kevin Marois31-Mar-22 8:11
professionalKevin Marois31-Mar-22 8:11 
GeneralRe: Access Android Tablet from C# Pin
OriginalGriff31-Mar-22 19:49
mveOriginalGriff31-Mar-22 19:49 
QuestionError when parsing string as int Pin
Member 1558328029-Mar-22 5:19
Member 1558328029-Mar-22 5:19 
AnswerRe: Error when parsing string as int Pin
Dave Kreskowiak29-Mar-22 5:33
mveDave Kreskowiak29-Mar-22 5:33 
QuestionFind the smallest integer that is not in a random array Pin
Member 1204230226-Mar-22 8:01
Member 1204230226-Mar-22 8:01 

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.