Linked Questions
5,416 questions linked to/from What is a NullReferenceException, and how do I fix it?
262
votes
8
answers
2.2m
views
What does "Object reference not set to an instance of an object" mean? [duplicate]
I am receiving this error and I'm not sure what it means?
Object reference not set to an instance of an object.
82
votes
5
answers
956k
views
Object reference not set to an instance of an object. [duplicate]
I keep getting this error when I run the program.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web ...
66
votes
2
answers
699k
views
How to solve Object reference not set to an instance of an object.? [duplicate]
In my asp.net program.I set one protected list.And i add a value in list.But it shows Object reference not set to an instance of an object error
protected List<string> list;
protected void ...
15
votes
5
answers
42k
views
Add element to null (empty) List<T> Property [duplicate]
I got a problem.
The problem is that I try to ad an object to a list of this objects.
This list is a property, no error, but when I run it fails at this point, becouse:
"NullReferenceException". ...
13
votes
2
answers
35k
views
Object Reference not set to an object (calling Razor model from View) [duplicate]
Using C# MVC4
My View:
@using Universe.Models
@model UserModel
@section css {
<link href="@Url.Content("~/Content/assets/charcreation.css")" rel="stylesheet"/>}
@using (Html.BeginForm("AddUser"...
8
votes
4
answers
49k
views
c# linq exception: object reference not set to an instance of an object [duplicate]
When I run a linq query I get back the results only when an item can be found; if no items are found, it is throwing an exception "object reference not set to an instance of an object"
How do I not ...
2
votes
9
answers
124k
views
object reference not set to an instance of object [duplicate]
I have been getting an error in VB .Net
object reference not set to an instance of object.
Can you tell me what are the causes of this error ?
3
votes
6
answers
5k
views
What is the meaning of NullReferenceException [duplicate]
Possible Duplicate:
What is a NullReferenceException in .NET?
For example, "System.NullReferenceException was unhandled", with Message "Object reference not set to an instance of an object."
...
7
votes
4
answers
8k
views
NullReferenceException was unhandled by user code - Object reference not set to instance of an object [duplicate]
I have the following C# classes:
public class Locales
{
public Region region { get; set; }
public Buttons buttons { get; set; }
public Fields fields { get; set; }
}
public class Region
{
...
1
vote
3
answers
28k
views
"Object reference not set to an instance of an object" error when trying to add objects to a list inside a class [duplicate]
I have some custom classes defined that include lists of other classes like so:
public class Unit
{
public string Name { get; set; }
public List<Group> Contains { get; set; }
}
public ...
6
votes
3
answers
15k
views
Correct syntax to initialize static array [duplicate]
I have following code definig an array
public class PalphabetsDic
{
public static string[] PAlphCodes = new string[3] {
PAlphCodes[0] = "1593",
PAlphCodes[1] = "1604",
...
1
vote
5
answers
41k
views
Can't catch NullReferenceException [duplicate]
First post here, so sorry if I've got some of the niceties wrong. I'm trying to catch an exception where the user enters an invalid (non-existent) employee. I've tried many different variations, but ...
5
votes
2
answers
39k
views
Check if datagridview cell is null or empty [duplicate]
I have to change the background color of the cells , when their value is string or empty, this is the code i have write similar to other codes here :
for (int rowIndex = 0; rowIndex < ...
6
votes
4
answers
7k
views
Object reference not set to an instance of object when using a List<T> in C# [duplicate]
I have the following code snippet that produces a compilation error:
public List<string> batchaddresses;
public MapFiles(string [] addresses)
{
for (int i = 0; i < addresses.Count(); i++...
2
votes
5
answers
9k
views
Get Object Reference Error when trying to use Request.QueryString [duplicate]
I have a page.aspx that reads the query string, and if the QueryString is something like page.aspx?id=1, it runs some code.
However, I want it to simply ignore that code if no QueryString is ...