62 Replies
UPD:
var stafftemp = temp[0];
returned me my itemSome additional screenshots to prove, that i have right id in
args.User.ID
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I know, i did this variant for debug
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
System.NullReferenceException
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Wait a second
Wtf? It just worked now, but i didn't change anything
But third line still not working
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
after i commented out three lines it broke down again :D
How does it work?)
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Maybe the error is in the DatabaseContext class. How is the data provided there?
are you sure args & User are not null?
Yes, this could also cause it since temp was not yet executed at this point and the iteration is not executed until FirtstOrDefault.
For testing just set args?.User?.Id
Yes, I have previously uploaded screenshots showing that
args.user
and staff stats is not null
I'm pretty sure the problem isn't with the database🤨
This is a very strange behavior.
Ohhh wait a minute.
I just noticed that your code continues to run without problems past the NullReferenceException point.
Which Visual Studio extension shows you this info on the side?
Probably just the extension can not create a reference at development time and comes for this reason to the exception.
If you make a try catch block around your code. Does it run into the catch block at all at some point?
ReSharper
It looks to me like resharper shows the error but does not occur in runtime.
VS without resharper runs this code with same result. It's just skip this error (also with try cath) and i can see this error only in debug
The last thing I can think of is that an element in the StaffMember is null. Try to enter a ? after the x.
x?.Id == args.User.Id
Otherwise, I have no further idea.
It's LinQ. It's can't contains
?
linq can
Are you actually getting a problem? ie you can see an exception in the locals window, not just in those 'lens' stuff
Yes, i have a check
staffMember == null
and because of this error, this check is skippedBecause
staffMember
is not null it is just nothing
Idk how does it workshow the call stack of the exception
I put this line in try catch but C# just skips this error and doesn't catch it
then it's not an error
Show the stack trace
If you can't, you're chasing hallucinations
How to get stack trace from this without try catch?
Sorry i just really don't know
$debug
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
the stack trace is a property on the exception
also click on this to be sure
https://www.christianfindlay.com/blog/visual-studio-break-on-all-exceptions
Visual Studio - Break On All Exceptions
Read about breaking on all exceptions in Visual Studio. This enables you to see the exact details of an exception instead of ignoring handled exceptions
If there's an exception the debugger stops. You dont need try/catch to see it
Still not working :(
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Because i did it for debug
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
This is whole my databasecontext
I am using EF Core for PostgreSQL btw
that is showing a 'debugger evaluation exception'. It is not an exception from the code that ran...
but since you're there, please expand
args
But i see this 'debugger evaluation exception' only in this place and my variable staffMember is empty only here...
you dont know what the value is if the locals evaluation is not working
What happens after the
if (staffMember == null)
line?Just an discord answer and it's just skip this line with this message:
lets ignore all the orange stuff - I dont trust it. You're still on that line. What happens next?
This
if
just skippedso it's not null
So theres no problem
I don't see what's inside this variable
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ok, but why i can get and see this
staffMember
in another part of my codeOh, i've read again and you mean
staffMembers
. I am not trying to check what inside staffMembers, i am trying to check what inside staffMember which i get with FirstOrDefault()
well if it works in one place, but not in another, then look at the differences
But there is no diffrerence...
Doesn't work:
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
it doesnt throw in actuality
It's just the debugger evaluation
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Anyway, I'm bored of saying the same thing and waffle showing the same 'problem' that has been explained