Skip to main content
1864 votes
26 answers
2.5m views

I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error?
324 votes
22 answers
1.4m views

I would like to prevent further processing on an object if it is null. In the following code I check if the object is null by either: if (!data.Equals(null)) and if (data != null) However, I ...
developer's user avatar
  • 7,430
270 votes
8 answers
2.4m views

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
220 votes
22 answers
702k views

This is probably the biggest waste of time problem I have spent hours on solving for a long time. var db = new hublisherEntities(); establishment_brands est = new establishment_brands(); est....
danielovich's user avatar
  • 9,757
198 votes
2 answers
9k views

This has got me stumped. I was trying to optimize some tests for Noda Time, where we have some type initializer checking. I thought I'd find out whether a type has a type initializer (static ...
Jon Skeet's user avatar
  • 1.5m
127 votes
20 answers
191k views

In C#, say that you want to pull a value off of PropertyC in this example and ObjectA, PropertyA and PropertyB can all be null. ObjectA.PropertyA.PropertyB.PropertyC How can I get PropertyC safely ...
Jon Kragh's user avatar
  • 4,739
70 votes
2 answers
717k views

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,837
67 votes
2 answers
10k views

I'm experiencing an interesting System.NullReferenceException whilst using the new null-conditional operator in C#. The following code gives me a NullReferenceException if "MyObject" is null: await ...
User_FSharp1123's user avatar
63 votes
6 answers
35k views

I've had an asp.net website running live on our intranet for a couple of weeks now. I just got an email from my application_error emailer method with an unhandled exception. Here it is (I've cleaned ...
RodH257's user avatar
  • 3,612
62 votes
4 answers
4k views

I have the following function: public static T TryGetArrayValue<T>(object[] array_, int index_) { ... //some checking goes up here not relevant to question dynamic boxed = array_[...
bedo's user avatar
  • 876
55 votes
3 answers
71k views

I have the following file structure: models/db.go type DB struct { *sql.DB } var db *DB func init() { dbinfo := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=disable", DB_USER,...
lionelmessi's user avatar
  • 1,154
51 votes
16 answers
18k views

I have a rather strange issue i'm not sure how to fix or if i can even fix it. I've done some research into the issue but can't find an answer to what's causing it. I'm following a rather simple ...
micah hawman's user avatar
49 votes
3 answers
25k views

I am doing a little debugging, and so I want to log the eventArgs value I have a simple line that basically does: logLine = "e.Value: " + IIf(e.Value Is Nothing, "", e.Value.ToString()) The way I ...
Nathan Koop's user avatar
  • 25.3k
44 votes
5 answers
67k views

I am using the following code within a class: string filePath = HttpContext.Current.Server.MapPath("~/email/teste.html"); The file teste.html is in the folder But when it will open the file the ...
soamazing's user avatar
  • 1,696
37 votes
1 answer
42k views

If we cast some null variable to a type, I expect the compiler to throw some exception, but it doesn't. Why? I mean string sample1 = null as string; string sample2 = (string)null; object t1 = null; ...
yigitt's user avatar
  • 838

15 30 50 per page
1
2 3 4 5
185