Questions tagged [nullreferenceexception]

The .NET exception that is thrown when there is an attempt to reference (or use) a null or uninitialized object.

A NullReferenceException occurs when you try to reference an object in your code that does not exist. For example, you may have tried to use an object without using the New keyword first, or tried to use an object whose value is set to null (Nothing in Visual Basic).

Troubleshooting Exceptions: System.NullReferenceException

Also, see "What is a NullReferenceException in .NET and how do I fix it?" for some hints.

2780 questions
0
votes
1 answer

Error when pulling from database to create objects after successful creation

Let me start by apologizing for the complexity of this post. hopefully I am missing something simple but in order to find out I have to make a lengthy explanation. I'm building a staff tracking app that allows users to draw polygons on a map. The…
Travis Fleenor
  • 167
  • 1
  • 11
0
votes
1 answer

NullPointerException on Image button

Whenever I click on the add post button it gives the error of java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageButton.setOnClickListener(android.view.View$OnClickListener)' on a null object reference I…
0
votes
1 answer

How to get a data in a text box by the index change of DropDownList in asp.net?

I am doing this using layer architecture and the code and problem is below. I want to get the course title in the text box by a course code of the DropDownList. The problem is null reference. Please help me to solve this problem. N.B: Course Code…
0
votes
1 answer

Null object detection

In my Drag and drop Listview i am collecting the dragged and dropped files by: var objects=Data.GetData(DataFormats.FileDrop, false); I can also cast this and i get paths of all dragged and dropped files: string[] DroppedDirectories =…
0
votes
1 answer

MVC 3 application on local IIS

I've had some interesting times deploying a MVC3 app to a localhost IIS server but this one cuts the cake. I am getting a null reference exception when hitting the site from a browser. To be clear, this application works on Cassini, IIS Express and…
jdiaz
  • 7,354
  • 12
  • 42
  • 51
0
votes
1 answer

ASP.NET MVC Object reference error

I have a very simple starter .NET application with this method in my controller: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using SampleMVC.Models; namespace…
Squiggs.
  • 4,299
  • 6
  • 49
  • 89
0
votes
2 answers

Skip item if null for xml text writer

I have Windows form C# application that takes values from the GUI and uses XML Textwriter to create an XML file from them. The problem is some of these values are meant to be optional and when the user leaves them blank, the application gets a null…
0
votes
2 answers

C# List not initializing

So I've got this class with two lists right now. One is getting initialized and one is not and I don't understand why. someList is just there, because I thought I am too stupid to initialize a list, but someList works just fine. Here's my…
Nicola K
  • 21
  • 2
0
votes
1 answer

NullReferenceException happen while importing an excel file mcv code

i put a break point at the beginning of import method and the code always enter the first condition even if i import an excel file and this cause the exception, the exception say that An exception of type 'System.NullReferenceException' occurred…
0
votes
1 answer

Unity-NullReferenceException When Using Composite Design Pattern

So I'm trying to make a simple dialogue tree in the form of a composite design pattern, where each member of the hierarchy has basically the same customizable properties, in this case, a question and two options. In Unity, I'm trying to assign the…
user8048595
  • 119
  • 1
  • 2
  • 12
0
votes
0 answers

NullReferenceException when initializing MySqlDB.MySql.MySql() buried in DLL

This is not a standard nullreferenceexception question because there are no objects instantiated that this initialization relies on, only namespaces I've been racking my brain for a couple of days on this one. The code works on another developer's…
Jesse Roper
  • 1,269
  • 7
  • 31
  • 56
0
votes
0 answers

Dependency Injection In View throws system.nullreferenceexception

Users are pointing me to Unity Dependency Injection from usercontrol viewmodel to customUsercontrol Viewmodel The top answer says Don't use DI/IoC container to inject controls If what im doing should NOT be done, at least advise on what i SHOULD…
highboi
  • 673
  • 7
  • 28
0
votes
1 answer

ASP.NET MVC code first related table null reference

I try to fetch user list from data base but some times 1 related table I call it is null and have not value for some user, so I get a null reference error. @if (@row.UserProfile.DoctorDetail.Id != null) { …
0
votes
1 answer

NullReferenceException using CloudRail LinkedIn Service

I am trying to connect to the LinkedIn API using CloudRail's LinkedIn .NET dll. I have the following code to set-up the LinkedIn service for my app: static void Initialize() { CloudRail.AppKey = "5-------9"; LinkedIn service = new LinkedIn( new…
0
votes
0 answers

C# datatable, get NullReferenceException on Clear

i need help to understand why i get this error on a line in my code an not at a line where i would expect it. I have a datatable object which i fill from a oracle select. After this i use this datatable as datasource for a datagridview. All fine. I…
MarcelS
  • 112
  • 9
1 2 3
99
100