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.

2616 questions
0
votes
0 answers

Error 'NullReferenceException: Object reference not set to an instance of an object' occurs only on the current project file in Unity

I am currently working on 2D platform game. The following script is supposed to disable the audio whenever the toggle button is off. using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; using…
0
votes
3 answers

Error in 'AddMessageEventListener' on GeckoFX

I want that my browser (GeckoFX) executes a .NET function when clicking on a button in my webpage. I have the following code: public Form1() { InitializeComponent(); AddMessageEventListener("myFunction", ((string s) =>…
jaume
  • 3
  • 4
0
votes
0 answers

odd even random pointer, linked list

I need to modify the SLL random pointers in such a way that ,All odd numbers in the list are connected by random pointers in the same order in which they are in SLL and the same for even numbers. I mean... I need to modify random pointers in such a…
0
votes
0 answers

Why does throw null throw NullReferenceException?

Why does this program compile? class Program { static void Main(string[] args) { throw null; } } From 8.9.5 of the C# Language Specification, A throw statement with an expression throws the value produced by evaluating the…
jdphenix
  • 13,519
  • 3
  • 37
  • 68
0
votes
1 answer

How to check null reference in lambda expression in .net

i am processing xml file by using following code,but how to check null reference exception which i used to get var main = System.Xml.Linq.XDocument.Load("1.xml"); string localcellid = main.Descendants() .FirstOrDefault(x =>…
peter
  • 7,172
  • 19
  • 57
  • 99
0
votes
0 answers

c# When trying to randomise a label 'System.NullReferenceException' occurred. No clear solutions found elsewhere

I am attempting to pass two values that match (match in hex and binary) and place them into a respective label randomly selected from an array of labels. I am only becoming familiar with the .NET framework (4.0). when I try to debug the program when…
The Boat
  • 27
  • 7
0
votes
1 answer

Unity - C# - attach GameObject to public Button CommunicationButton;

I cannot solve this problem, I hope someone knows how to do this. What I have A button and a text field on a canvas, see image: I have a script called HumanInstructions, that initializes like this: public Text CommunicationMessage; public Button…
JuliusSecret
  • 149
  • 1
  • 2
  • 12
0
votes
1 answer

Unity - C# - NullReferenceException: Object reference not set to an instance of an object

EDIT My question is different (I think..) because the last image allows me to set a GameObject to the Communication Message and Communication Message. BUT, on play, it immediately resets to None (Text) and None (Button). I don't know why this…
JuliusSecret
  • 149
  • 1
  • 2
  • 12
0
votes
0 answers

Visual Studio file input NullReferenceException was unhandled c#

I have tried looking at other peoples questions to find a solution however just cannot understand what/why this is happening. If someone can take a look at this code and explain why this is causing it may give me a better understanding private…
C. Dodds
  • 193
  • 9
0
votes
1 answer

"Object reference not set to an instance of an object." when setting a listview template

I'm trying to switch between 2 templates on the basis of a data trigger. But I app crashes with the "Object reference not set to an instance of an object." If I comment out the setter for the template it runs fine. Here's my XAML:
0
votes
1 answer

NullReferenceException on web user control

First time posting. :) I'm a pretty new developer so I'm not well versed in common ASP.NET problems. As a test, my boss asked me to convert a (not very critical) ASP.NET site from 1.1 to 4.0. Well, it's not extremely difficult and things are going…
0
votes
1 answer

null reference exception on using DefaultIfEmpty()

I wrote the below sql query SELECT * FROM dbo.PR_ADDRESS LEFT OUTER JOIN dbo.Book_MarkText ON dbo.PR_ADDRESS.GroupID = dbo.Book_MarkText.BMData where dbo.PR_ADDRESS.GroupID = dbo.Book_MarkText.BMData OR …
pravprab
  • 2,255
  • 3
  • 24
  • 40
0
votes
2 answers

Null Reference exception in FirstOrDefault C#

I have this line: myobject.Ada = result.FirstOrDefault(m => m.Name == "Ada No").Value; Sometimes result doesn't have "Ada No" and I get Object reference not set to an instance of an object. I wrote an if statement to avoid null reference…
jason
  • 6,163
  • 28
  • 94
  • 178
0
votes
0 answers

HttpStatusCode.NotFound is giving error now c#

I have a code for checking if response is error 404 an if it is set an image from resources that code works fine before but now it is giving error I don't know why. Here is the code try { picture.Load(img); } …
P.RAO
  • 41
  • 8
0
votes
1 answer

Why is some of the colorization of cells not occurring, and is there a connection between that and the "Cannot perform runtime binding" err msg?

I'm getting the following err msg: This is occurring in this code: private bool GetContractForDescription(string desc) { int DESCRIPTION_COL_NUM = 2; int CONTRACT_COL_NUM = 7; bool contractVal = false; int rowsUsed =…
B. Clay Shannon
  • 1,055
  • 124
  • 399
  • 759
1 2 3
99
100