Questions tagged [nullreferenceexception]

The .NET exception that is thrown when there is an attempt to reference (or use) a null or uninitialized object.

A NullReferenceException occurs when you try to reference an object in your code that does not exist. For example, you may have tried to use an object without using the New keyword first, or tried to use an object whose value is set to null (Nothing in Visual Basic).

Troubleshooting Exceptions: System.NullReferenceException

Also, see "What is a NullReferenceException in .NET and how do I fix it?" for some hints.

2780 questions
0
votes
1 answer

java.lang.NullPointerException Errors PLEASE

Im really new to coding and ive been trying to make this minecraft plugin. Every time I launch it I get this error. https://i.imgur.com/33lBHQr.png Here is the "launcher.NitroLauncher.onEnable" class. package launcher; import…
0
votes
0 answers

Equals method throws NullReferenceException

I recently came about this problem. I have a base Stamp class. Then I made two inherited classes OwnedStamp and AuctionStamp. I overrided the Equals and GetHashCode method in Stamp class like this: public override bool Equals(object obj) { …
EIMA
  • 11
  • 3
0
votes
0 answers

System.NullReferenceException when I test if NetworkStream is null

if I try to test this if (mydeviceconnection.Devicestream != null) I get System.NullReferenceException. Visual studio says: mydeviceconnection.Devicestream was null. Devicestream is a NetworkStream part of mydeviceconnection class. I am trying…
qfactor77
  • 810
  • 7
  • 10
0
votes
1 answer

why this (not set to an instance of an object ) error showing to me?

I am trying to make this code work by checking if there is a movie id in the link so it will render different text than if there is no id @if (Model.Movie.Id != null)
Edit316
  • 1
  • 1
0
votes
0 answers

Xamarin.Forms ZXing Qr-Code Scanner System.NullReferenceException: 'Object reference not set to an instance of an object.'

i'm making a xamarin.forms app with qr-code login. When qr-code is valid its ok user is login , but when it's not ok i got System.NullReferenceException: 'Object reference not set to an instance of an object.' at the end of …
Razzzz
  • 381
  • 2
  • 17
0
votes
0 answers

Unity nullreferenceexception in arrays

I'm trying to make a minecraft like game and myscript throws a NullReferenceException for some reason when i'm generating UVs for my Block. I've tried to change some variables but it didn't help. BlockType.cs: public class BlockType { public…
Bartek Dusza
  • 174
  • 1
  • 10
0
votes
0 answers

How to fix string keep returning null c#

I'm currently writing an api wrapper. To be able to send api request you need an authorization token but the code i currently have doesn't return a value. public string Token { get { return HttpClient.Token; } set { …
Xaxlii
  • 1
  • 1
0
votes
2 answers

Unknown NULL value accessed

this a partial program of AVL tree, but right now its just more of a BST #include #include #include typedef struct node node; struct node { int data; int height; node *left; node *right; } *root = NULL,…
Piyush Kumar
  • 191
  • 1
  • 10
0
votes
1 answer

C#/Visual Studio trying to change the content of random array and getting 'Object reference not set to an instance of an object.' error

I am trying to make a tic tac toe game where the user inputs the dimensions and then a board is created with buttons. When a button is clicked, it is disabled and the text inside changes to "X" or "O" accordingly. The user plays against a very basic…
0
votes
1 answer

Firebase Auth returns System.NullReference exception

I am new to this. When I try to create a user with email and password it tells me that my FirebaseAuth is null and doesn't let me create a user. I am initializing Firebase through this. void InitializeFirebase() { var app =…
0
votes
2 answers

Initialization in a parameterless constructor should be avoided?

some of my colleagues demand to avoid parameterless constructor and it's initialization completly. Because they tell me that a default initialization of a string property for example quickly hides the ability to find out the source of the error.…
Benjamin Martin
  • 576
  • 1
  • 8
  • 27
0
votes
1 answer

How skip NullReferenceException in Get API

Here create an API to get the records, in my entity relation table there are twice start date and end date. Here my compulsion is one of them need to keep Null able type. Here is ER that is SchoolCourses: public class SchoolCourses { public…
Vipin Jha
  • 117
  • 1
  • 2
  • 16
0
votes
2 answers

Attempt to invoke virtual method on a null object reference while starting an Intent

First of all i know that there are tons of those questions already but believe me i searched and haven't found anything that would solve my problem Situation looks like this. I try to start new intent in recyclerView adapter in onClick method and…
Vesspe
  • 61
  • 1
  • 3
  • 9
0
votes
0 answers

Leetcode Problem Runtime error: reference binding to null pointer of type 'struct value_type' (stl_vector.h)

Original Leetcode Problem: https://leetcode.com/explore/interview/card/top-interview-questions-easy/94/trees/628/ When I change line 23 to while (result.size() < t.second+1) it works fine, but it doesn't work when I have while (result.size()-1 <…
0
votes
1 answer

HtmlAgilitypack SelectSingleNode "System.NullReferenceException"

This is my code: var html = webBrowser1.DocumentText; HtmlWeb web = new HtmlWeb(); var htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(html); var node =…
Game Lion
  • 61
  • 1
  • 7