nullreferenceexception

Null reference but it's not?

This is related to my previous question but it is a different problem. I have two classes: Server and Database. Public Class Server Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Private _databases As List...

Whose fault is a NullReferenceException?

I'm currently working on a class which exposes an internal List through a property. The List shall and can be modified. The problem is, entries in the internal list could be set to null from outside the class. My code actually looks like this: class ClassWithList { List<object> _list = new List<object>(); // get accessor, whic...

ViewState is NULL in Page_Load but not postback

I've got a weird problem with a NullReferenceException on a high traffic website my company hosts. The exceptions are logged with full stack-traces but I am unable to reproduce it. The exception occurs a couple of times a day, for different users, and it's a NullReferenceException thrown in the code block below: protected void Page_Lo...

.NET - Very strange NullReferenceException?

How can I get a NullReferenceException in the following scenario? Dim langs As IEnumerable(Of SomeCustomObject) = //some LINQ query If langs Is Nothing Then Return Nothing If langs.Count = 1 Then //NullReferenceException here What am I missing here? Debug shows that langs is really just a LINQ queryresult without any results... ...

VB.NET - Object reference not set to an instance of an object

I need some help with my program. I get this error when I run my VB.NET program with a custom DayView control. ***** Exception Text ******* System.NullReferenceException: Object reference not set to an instance of an object. at SeaCow.Main.DayView1_ResolveAppointments(Object sender, ResolveAppointmentsEventArgs args) in C:\Us...

Disposing the members that implement IDisposable.

In my Dispose methods (like the one below), everytime i want to call someObj.Dispose() i also have a check for someObj!=null. Is that because of bad design on my part? Is their a cleaner way to ascertain that Dispose of all the members (implementing IDisposable) being used in an object is called without having a risk of NullReference e...

GetAdornerLayer mysteriously returning null

I've been using the same bit of code for several versions of my app with no problems, but I'm now mysteriously receiving NullRerefenceExceptions with the following: this.Loaded += delegate { deleteBrush = new DeleteBrushAdorner( background ); AdornerLayer al = AdornerLayer.GetAdornerLayer( background ); al.Add( deleteBrush )...

ASP.NET MVC NullReferenceException when inheriting from a Base Controller

I've got a base controller that I inherit all of my Controllers from. It's job is to basically set caching and error handling as well as check for mobile browsers. My UI works fine, but my Unit Tests are failing. Imports System.Web.Mvc <HandleError()> _ <CompressFilter()> _ <OutputCache(Duration:=30, VaryByParam:="id")> _ Public Clas...

ASP.NET MVC: null reference exception using HtmlHelper.TextBox and custom model binder

I have written a class which implements IModelBinder (see below). This class handles a form which has 3 inputs each representing parts of a date value (day, month, year). I have also written a corresponding HtmlHelper extension method to print out three fields on the form. When the day, month, year inputs are given values which can be p...

Why do I get this System.NullReferenceException?

I'm getting a weird error. I have the following front-end code: <%@ Page Title="" Language="C#" MasterPageFile="~/nokernok/MasterPages/nokernok.Master" AutoEventWireup="true" CodeBehind="articleList.aspx.cs" Inherits="development.nokernok.articleList" %> <%@ Register TagPrefix="EPiServer" Namespace="EPiServer.WebControls" Assembly="EPiS...

Null check always returns null, if removed returns Object reference not set to an instance of an object.

I have some code which gets child items for a menu via the GetChildren function which takes a list of menuData: Dim builtMenu As New List(Of MenuData)(_rawData.FindAll(Function(item) item.GroupingID = 0)) For Each menuData As MenuData In builtMenu If menuData.Children IsNot Nothing Then menuData.Children.AddRan...

ASP.NET session lost but only for one particular user

I have an ASP.NET application that is running on two load balanced servers. Everything is working fine except for one group of customers. All of these customers are coming from the same company. Randomly, an unhandled NullReferenceException error is thrown. It happens at random times in random places. It seems as if the session is j...

I seem to have fallen into some massive, massive trouble with NullReferenceExceptions.

Recently I'm developing a software that parses and displays XML information from a website. Simple enough right? I'm getting LOADS of NullReferenceExceptions. For example, this method: private void SetUserFriends(List<Friend> list) { int x = 40; int y = 3; if (list != null) { foreach (Friend friend in list) ...

Is this really a possible InvalidOperationException?

I have a Linq2Sql query that looks like this: var data = from d in dc.GAMEs where (d.GAMEDATE + d.GAMETIME.Value.TimeOfDay) >= DateTime.Now && d.GAMESTAT == 'O' && d.GAMETYPE == 0 select d; Resharper is underlining the "d.GAMETIME.Value.TimeOfDay" in blue and telling me it's a possible System.InvalidOperationException. Wh...

Bizzare APS.net "Object reference not set to an instance of an object"

So a bit of an overview around the lead up to this exception. I've created a website on my dev machine (windows xp, asp.net 4) and targeted it to .Net 3.5. I then deployed the 100% working website on the stage machine (Windows 7, ASP.net 2, IIS 7.5). After sorting out numerous security problems, I've come to a stop at this bewildering...

no source available when debugging c# app which references f# lib

In my solution of VS2010, a C# app project references a F# library project. When a NullReferenceException is thrown from F# lib, the debugger cannot find the point exception thrown. It just says 'No Source Available'. Should I change some options or this is a limitation of VS2010? I added some example code: F# project 'Library1' mod...

WPF Designer ONLY: NullReferenceException when loading connection string from app.config

Please help, for the sake of my non-pulled out hair... The following code line: this._connectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString; is causing me untold amounts of grief. It is in a user control, currently in the control's Loaded event but I've also tried the constructor and just...

c# code seems to get optimized in an invalid way such that an object value becomes null

I have the following code that exhibits a strange problem: var all = new FeatureService().FindAll(); System.Diagnostics.Debug.Assert(all != null, "FindAll must not return null"); System.Diagnostics.Debug.WriteLine(all.ToString()); // throws NullReferenceException The signature of the FindAll method is: public List<FeatureModel> FindA...

NullReferenceException on code that should work.

I have the following controller Action: public ActionResult Details(int id) { Seguimiento seguimiento = repo.GetSeguimiento(id); if (seguimiento == null) { return View("NotFound"); } else { return View("Details", seguimiento)...

If null.Equals(null) why do I get a NullReferenceException

I have the following line of code --> var selectedDomainID = lkuDomainType.EditValue.Equals(null) ? string.Empty : lkuDomainType.EditValue; that is, sometimes, generating a NullReferenceException What I don't understand is why. Isn't the whole point of my code to check for null and if so assign string.empty?? When I check in DEBUG ...