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

Xamarin.Forms app works on iOS, throws error on Android ("Object reference not set to an instance of an object")

I'm new to Xamarin.Forms. I got an app that works well on iOS. However, on Android, it crashes after some time, and throws the following error: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an…
Etienne Juneau
  • 633
  • 5
  • 11
0
votes
0 answers

DataContext.SubmitChanges() throws NullReferenceException everytime I want to update connected database

As I said in the title of the topic, I have a problem with DataContext.SubmitChanges() method. I have two tables: Users and Administrators (and other roles as Doctors etc, but now I am working with these two tables). SQL scripts for those two…
0
votes
2 answers

Object reference and assigning new class with it

Trying to pass the object reference and set it in the new script/class. Player.cs How do i go about referencing correctly, and assigning
user3072143
  • 77
  • 1
  • 2
  • 7
0
votes
0 answers

Xamarin C# MainAvtivity.Intent is null

I'm Creating a Call Diverting app using Xamarin. What i am doing is with the press of a button a command is triggerd and using DependencyService i call the Android specific implementaion of the Call Diverter Method. Now I'm having a problam where…
MetaDude
  • 139
  • 5
  • 14
0
votes
1 answer

VB.net Working with GroupBox in Array

I am writing a program which involves a few Groupboxes and a sub-routine to manipulate the controls in each of the groupboxes (e.g. add buttons, remove controls) according the variables given e.g. GroupBA, GroupBD....etc. However, I received…
0
votes
1 answer

NullReferenceException WIA C#

When I run the code below I get this error NullreferenceException was unhandled.. below is my code private void showScannerDialog() { this.scanner = null; this.imageItem = null; this.getScanner(); …
user400749
  • 195
  • 1
  • 4
  • 11
0
votes
1 answer

Unity saving inputfield

I am making a 2D platformer where I want the users inputted name to hover over there character. This is what the menu screen looks like using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using…
spark
  • 25
  • 1
  • 6
0
votes
0 answers

Why does my checkedListBox throws NullReferenceException in C#?

I am trying to populate my checkedListBox with a txt file. Here is my code: public Form1() { StreamReader sr1 = new StreamReader(allatPath, Encoding.Default); while(!sr1.EndOfStream) { allat = new Allat(sr1.ReadLine(),…
user3599604
  • 31
  • 10
0
votes
1 answer

Attempt to invoke virtual method '...distanceTo' on a null object reference

I have looked everywhere I possibly can and found nada. It's been a few hours that I am trying to solve this thing out yet no luck. I have a function that is meant to acquire my location once through requestLocationUpdates and then…
Tomer
  • 79
  • 11
0
votes
0 answers

Xamarin latest update findviewbyid returns null

I just installed the latest update of Xamarin for Visual Studio. Ever since, android can't find the views in my activity layouts. Apparently the auto-generated IDs aren't updated correctly when i just save my resources. If I clean the project and…
0
votes
1 answer

xdocument create from scratch

Noobie to the XML/Xdocument world. Trying to create an Xdocument with a variable number of DataField elements which are passed in as a List of Tuples. This document is used as part of an API call to edit fields in a record on a distant server. When…
nelchr
  • 3
  • 1
0
votes
1 answer

I get NullReferenceException error but I don't know why?

I know that this error is shown where object is null. But in my case I'm not sure why is it shown. I tried to create 10 PictureBox objects on every 30px of width randomly, on timer_tick and here is my code. PictureBox[] meteor; int i=0; Random rnd =…
Danilo Ivanovic
  • 1,216
  • 1
  • 10
  • 18
0
votes
0 answers

C# object reference gets SOMETIMES lost in Threads that end via EventHandler

I have a strange problem with following code, that is started about every minute. Normally everything works fine, but sometimes the HandleCalcStatistikMarkersDone function raises an error because of a NullReferenceException. I try to explain with…
Airwave
  • 136
  • 4
  • 15
0
votes
1 answer

C# accessing array of static objects

so I'm working on a text based game and I'm running into an issue of an aray of object not being populated properly during run-time. I'm not entirely sure why this is happening, but here is the code: public class Area { public List
Raxmo
  • 57
  • 5
0
votes
0 answers

VB.net Process.Start starts process but leaves variable as nothing

To start I would only rate myself as a novice programmer as I only know the concepts I've needed to learn to accomplish specific tasks at my work. That being said I'm using Process.Start to open the built-in Windows to camera program but when I do…
Chris P.
  • 1
  • 1
1 2 3
99
100