Click here to Skip to main content
15,116,516 members
Home / Discussions / C#
   

C#

 
JokeRe: Can't catch NullReferenceException while explicitly defined for that Pin
Pete O'Hanlon2-Oct-21 2:32
mvePete O'Hanlon2-Oct-21 2:32 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
OriginalGriff2-Oct-21 3:14
mveOriginalGriff2-Oct-21 3:14 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Exoskeletor2-Oct-21 4:01
MemberExoskeletor2-Oct-21 4:01 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Pete O'Hanlon2-Oct-21 4:51
mvePete O'Hanlon2-Oct-21 4:51 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
OriginalGriff2-Oct-21 4:55
mveOriginalGriff2-Oct-21 4:55 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Exoskeletor2-Oct-21 4:58
MemberExoskeletor2-Oct-21 4:58 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Exoskeletor2-Oct-21 3:58
MemberExoskeletor2-Oct-21 3:58 
AnswerRe: Can't catch NullReferenceException while explicitly defined for that Pin
Pete O'Hanlon3-Oct-21 21:22
mvePete O'Hanlon3-Oct-21 21:22 
You're making the assumption that the method that is throwing the null reference is inside your task. What's interesting is that you have failed to apply any forms of input guards to SearchMostLessViewsAsync and you're assuming you actually have values coming in. It wouldn't surprise me if the null reference you are seeing occurred in this call:
C#
Microsoft.AppCenter.Analytics.Analytics.TrackEvent($"{typeof(FragmentDrawsNumbersFrequency).Name}.{nameof(SearchMostLessViewsAsync)}",
    new Dictionary<string, string>()
        {
            {nameof(dateFrom), dateFrom.ToString()},
            {nameof(dateTo), dateTo.ToString()},
            {nameof(amountOfNumbersSelected), amountOfNumbersSelected.ToString()},
            {nameof(frequencyOption), frequencyOption.ToString()},
            {nameof(fromDrawNumber), fromDrawNumber.ToString()},
            {nameof(toDrawNumber), toDrawNumber.ToString()},
        }
    );
If any of those is null, you'll get a null reference because you're calling ToString() on it. The bottom line is that you shouldn't make assumptions about where exceptions are occurring; look at the whole part of the code.

GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Exoskeletor4-Oct-21 1:21
MemberExoskeletor4-Oct-21 1:21 
Questionhow read file from Open with in C# Pin
Member 1522978130-Sep-21 7:24
MemberMember 1522978130-Sep-21 7:24 
AnswerRe: how read file from Open with in C# Pin
Dave Kreskowiak30-Sep-21 9:08
mveDave Kreskowiak30-Sep-21 9:08 
AnswerRe: how read file from Open with in C# Pin
Luc Pattyn30-Sep-21 9:30
sitebuilderLuc Pattyn30-Sep-21 9:30 
QuestionQuestion About Async Pin
Kevin Marois29-Sep-21 11:21
professionalKevin Marois29-Sep-21 11:21 
AnswerRe: Question About Async Pin
Pete O'Hanlon29-Sep-21 21:22
mvePete O'Hanlon29-Sep-21 21:22 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 5:24
professionalKevin Marois30-Sep-21 5:24 
GeneralRe: Question About Async Pin
Richard Deeming30-Sep-21 5:41
mveRichard Deeming30-Sep-21 5:41 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 5:48
professionalKevin Marois30-Sep-21 5:48 
GeneralRe: Question About Async Pin
Richard Deeming30-Sep-21 6:05
mveRichard Deeming30-Sep-21 6:05 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 6:20
professionalKevin Marois30-Sep-21 6:20 
AnswerRe: Question About Async Pin
Richard Deeming29-Sep-21 22:54
mveRichard Deeming29-Sep-21 22:54 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 5:23
professionalKevin Marois30-Sep-21 5:23 
QuestionMakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 6:45
mveBillWoodruff28-Sep-21 6:45 
AnswerRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
Richard Deeming28-Sep-21 7:20
mveRichard Deeming28-Sep-21 7:20 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 10:47
mveBillWoodruff28-Sep-21 10:47 
AnswerRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
OriginalGriff28-Sep-21 7:30
mveOriginalGriff28-Sep-21 7:30 

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.