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

Object reference not set to an instance of an object - What object isn't being referenced?

I'm trying to make a script that gives the player a stronger attack when a powerup is walked over. It worked fine with a health increase that I made, but I cannot seem to pin down what I'm doing wrong with this one. I've been at it for the past few…
Amy Walker
  • 35
  • 2
0
votes
0 answers

NullReferenceException epplus Parallel.For

Good afternoon, I just want to apologize for my English. I am writing a program (using the epplus library), which takes an excel file and looks for matches. When it finds replaces some cells. Everything works fine, but for a long time. I decided to…
Hash
  • 1
  • 1
0
votes
0 answers

Assign value to model in asp.net mvc C# returns "NullReferenceException was unhandled by user code "

I am trying to get current time with DateTime.Now.ToString() and to assign as a value to Model.DatePosted, using Razor in my View.The problem is always when i try to add value to DatePosted I get NullReferenceException. I think I dont have problem…
Zoran Zoki
  • 128
  • 7
0
votes
1 answer

Null object Refrence Error only on web C# asp

I know this question has been asked but I don't see anything that helps me. What I have is a ticket application that records trouble tickets then sends an email to the right person. When I run this on my machine it works, but on my server I get a…
Travis J
  • 109
  • 3
  • 11
0
votes
0 answers

How to write a unit test for files removed

I am now fixing a defect, the original code is like below: public void Run() { var tempOutputDir = new DirectoryInfo("d:\Test\"); GenerateFiles(tempOutputDir); var result = RunToStreamCore(tempOutputDir); } void GenerateFiles() { //…
0
votes
2 answers

object references not set to an instance of the object

Am running asp.net application with c#.Am using gridview to update and delete the columns.deleting is working fine.if am clicking the update button i got System.NullReferenceException: Object reference not set to an instance of an object. My code…
jeni
  • 973
  • 4
  • 18
  • 32
0
votes
1 answer

Null reference error when assigning a value into custom type array via WSDL

I have a WSDL: http://kinkom.dk/WCFAPP/SI_CreateSM_OB_7.wsdl (I have changed address location). My code is for accessing data from SAP via WSDL; bind that to .NET control as well as sending data from .NET control to SAP via same WSDL. The code is…
Paul
  • 23
  • 7
0
votes
1 answer

Vb 10 nullreference exception

i got this code from the net , but i can't make this code work on the system i am programming so, i used the same codes to another system and it worked, when i tried using it to my system, it failed, so i started a new program and it still fails...…
0
votes
0 answers

Null reference error when calling a method

I have a method called NewBatch_GetAndSetBatchID. When I call this methode in the Page_Load methode it works perfectly. But when I call this methode from a button (on the same page), I get: Null reference exeption Object reference not set to an…
Mart Apon
  • 69
  • 1
  • 1
  • 8
0
votes
0 answers

System Execution Engine exception on object that passes null guard

Hello can someone please explain me how can one object pass through a NULL guard then throws exception when trying to acess non-nullable field? (bool) As you can see in the method above our object response of type Node is not null.Focus your…
0
votes
1 answer

insert stored procedure with set null parameters in entity framework

I want to insert null parameter in some values, but I get the following error : System.NullReferenceException: 'Object reference not set to an instance of an object.' System.Windows.Forms.ListControl.SelectedValue.get returned null. The…
solmaz ahamdi
  • 150
  • 1
  • 11
0
votes
1 answer

Cannot perform runtime binding on null reference C# Excel

I have found many questions similar to this, but none that solve my issue. I am using SSIS and a C# script to read and modify the styling of an Excel workbook. I get the following error "Cannot perform runtime binding on null reference". I…
Mark
  • 691
  • 7
  • 20
0
votes
2 answers

Unexplainable Null Reference Exception in VB.NET

I have an application for working with files. It needs to work with the files one character at a time. I am using an ArrayList to store the data. Here's the code that's causing the problem: Dim fileData As ArrayList = Nothing Dim temp As Char =…
0
votes
1 answer

Why am I getting a NullReferenceException when subscribing to event in Xamarin.Forms, but only on iOS?

I have a page - Page A, that has a method that subscribes to an event on another page - Page B. I figured I could instantiate Page B in my code in Page A before having my method in Page A subscribe to the event in Page B, and then finally pushing…
chungmcl
  • 310
  • 1
  • 3
  • 14
0
votes
0 answers

Value cannot be null parameter name items MVC 5 (DropDownList)

I am trying to add roles to my existing Identity framework. For that part I have modified my account controller as follows: public ActionResult Register() { List list = new List(); foreach…