Linked Questions

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.
mohammad reza's user avatar
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 ...
Mike's user avatar
  • 2,313
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 ...
r.vengadesh's user avatar
  • 1,787
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". ...
Sinmson's user avatar
  • 227
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"...
ArjaaAine's user avatar
  • 896
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 ...
Demodave's user avatar
  • 6,542
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 ?
sef's user avatar
  • 5,275
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." ...
user avatar
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 { ...
anitacynax's user avatar
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 ...
thanby's user avatar
  • 323
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", ...
Ali Padida's user avatar
  • 1,901
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 ...
mojo's user avatar
  • 69
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 < ...
alejandro carnero's user avatar
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++...
JOE SKEET's user avatar
  • 8,048
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 ...
Boxiom's user avatar
  • 2,295

15 30 50 per page
1
2 3 4 5
362