Click here to Skip to main content
15,880,796 members
Home / Discussions / C#
   

C#

 
AnswerRe: Data format for non-computerist editing Pin
Gerry Schmitz23-Dec-20 6:46
mveGerry Schmitz23-Dec-20 6:46 
AnswerRe: Data format for non-computerist editing Pin
Mycroft Holmes23-Dec-20 11:14
professionalMycroft Holmes23-Dec-20 11:14 
AnswerRe: Data format for non-computerist editing Pin
jschell29-Dec-20 6:54
jschell29-Dec-20 6:54 
QuestionHow to address SQL CE file path? Pin
Alex Dunlop22-Dec-20 7:46
Alex Dunlop22-Dec-20 7:46 
AnswerRe: How to address SQL CE file path? Pin
OriginalGriff22-Dec-20 8:45
mveOriginalGriff22-Dec-20 8:45 
QuestionWhy does NullReferenceException throw irrelevantly? I already tried - no success. Pin
Jens Eckervogt22-Dec-20 0:18
Jens Eckervogt22-Dec-20 0:18 
AnswerRe: Why does NullReferenceException throw irrelevantly? I already tried - no success. Pin
Richard MacCutchan22-Dec-20 1:06
mveRichard MacCutchan22-Dec-20 1:06 
AnswerRe: Why does NullReferenceException throw irrelevantly? I already tried - no success. Pin
OriginalGriff22-Dec-20 1:12
mveOriginalGriff22-Dec-20 1:12 
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, VS 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, VS 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!
"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: Why does NullReferenceException throw irrelevantly? I already tried - no success. Pin
Gerry Schmitz22-Dec-20 3:33
mveGerry Schmitz22-Dec-20 3:33 
SuggestionSQLLight vs SQL CE Pin
Alex Dunlop20-Dec-20 8:16
Alex Dunlop20-Dec-20 8:16 
GeneralRe: SQLLight vs SQL CE Pin
Gerry Schmitz20-Dec-20 9:19
mveGerry Schmitz20-Dec-20 9:19 
GeneralRe: SQLLight vs SQL CE Pin
Mycroft Holmes20-Dec-20 11:15
professionalMycroft Holmes20-Dec-20 11:15 
QuestionHow to save panel content into PDF Pin
RedPandinus19-Dec-20 17:46
RedPandinus19-Dec-20 17:46 
AnswerRe: How to save panel content into PDF Pin
OriginalGriff19-Dec-20 19:57
mveOriginalGriff19-Dec-20 19:57 
SuggestionRe: How to save panel content into PDF Pin
RedPandinus19-Dec-20 20:30
RedPandinus19-Dec-20 20:30 
GeneralRe: How to save panel content into PDF Pin
OriginalGriff19-Dec-20 22:57
mveOriginalGriff19-Dec-20 22:57 
GeneralRe: How to save panel content into PDF Pin
RedPandinus20-Dec-20 6:07
RedPandinus20-Dec-20 6:07 
GeneralAForge Motion Detection from PictureBox? Pin
Herboren19-Dec-20 17:15
Herboren19-Dec-20 17:15 
GeneralRe: AForge Motion Detection from PictureBox? Pin
Gerry Schmitz19-Dec-20 21:51
mveGerry Schmitz19-Dec-20 21:51 
GeneralRe: AForge Motion Detection from PictureBox? Pin
Herboren20-Dec-20 6:09
Herboren20-Dec-20 6:09 
GeneralRe: AForge Motion Detection from PictureBox? Pin
Gerry Schmitz20-Dec-20 9:30
mveGerry Schmitz20-Dec-20 9:30 
GeneralRe: AForge Motion Detection from PictureBox? Pin
Herboren20-Dec-20 12:47
Herboren20-Dec-20 12:47 
GeneralRe: AForge Motion Detection from PictureBox? Pin
Gerry Schmitz21-Dec-20 6:52
mveGerry Schmitz21-Dec-20 6:52 
GeneralRe: AForge Motion Detection from PictureBox? Pin
Herboren21-Dec-20 8:31
Herboren21-Dec-20 8:31 
GeneralRe: AForge Motion Detection from PictureBox? Pin
Gerry Schmitz21-Dec-20 8:57
mveGerry Schmitz21-Dec-20 8:57 

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.