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?
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
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
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
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
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
27 votes
18 answers
40k views

Apparently the vast majority of errors in code are null reference exceptions. Are there any general techniques to avoid encountering null reference errors? Unless I am mistaken, I am aware that in ...
Nippysaurus's user avatar
  • 20.4k
24 votes
5 answers
6k views

using System; using System.Collections.Generic; class Parent { public Child Child { get; set; } } class Child { public List<string> Strings { get; set; } } static class Program { ...
Ajai's user avatar
  • 338
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
29 votes
7 answers
54k views

I'm new to Android developing and of course on Fragments. I want to access the controls of my fragment in main activity but 'findViewById' returns null. without fragment the code works fine. Here's ...
mammadalius's user avatar
  • 3,363
12 votes
5 answers
13k views

When using calling the SqlCommand.ExecuteReader() method, ReSharper tells me I have a possible NullReference exception when I use the SqlDataReader object afterwards. So with the following code: ...
Ray's user avatar
  • 46.8k
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
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
33 votes
3 answers
154k views

I have the following VBScript in a Classic ASP page: function getMagicLink(fromWhere, provider) dim url url = "magic.asp?fromwhere=" & fromWhere If Not provider is Nothing Then ' ...
Vivian River's user avatar
  • 32.7k
23 votes
4 answers
3k views

From previous experience I had been under the impression that it's perfectly legal (though perhaps not advisable) to call extension methods on a null instance. So in C#, this code compiles and runs: /...
Dan Tao's user avatar
  • 129k

15 30 50 per page
1
2 3 4 5
13