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

Problem in sending session to view at Asp.Net MVC

I want to prevent clients to access route Home/Index when they are not logged in. So the code in my view is here: @{ Layout = null; if (Session["userId"]==null) { Response.Redirect(Url.Action("Index","Login")); …
0
votes
1 answer

Cannot access stage properties from a method?

I have an object on my stage, called obj. I also have a class called "Physics" which contains a bunch of methods for physics, such as inertia, gravity, and bouncing off walls. In order to do some of these, I need access to the stage.stageWidth and…
0
votes
0 answers

player object is null c#

am new here sorry if am posting wrong you can ask me for more info if am not gived much in code. I try to fix my issue but its anoying like 5 days now in row i try every method to fix it but it wont help. The real problem is my screen starts…
0
votes
1 answer

Windows Service NullReferenceException C#

I'm trying to create a Web API service but when I'm trying to run as service I get NullReferenceException. It's working well if I remove the ServiceBase part. If I replace the Thread to do nothing, then it's working as usual. What could be causing…
Foong
  • 45
  • 6
0
votes
1 answer

I want to make a incremental game in Xamarin, and i made some timers that give me an exception error

I am a beginner and i want to make a clicker game with an orange for android, but i get a null reference exception error, i search how to fix but still not working. This is my first question. Here is my MainActivity.cs Code [Activity(Label =…
0
votes
3 answers

DataTable Rows Count Null Exception

Im trying to fill a listview with data from my database but get a null reference exception when i load the listview. Im using MVC pattern. Code in my data acces layer: public List DB_Get_All_MenuItems() { string query = "SELECT * FROM…
0
votes
1 answer

ASP.NET Site, error when publish

Possible Duplicate: NullReferenceException when running published website in IIS i got problem when a publish my site in the IIS 7.5 2008 Server. In my local pc it is located in D:\projects\visual_studio\site, then when i publish to the server,…
Michel Andrade
  • 4,056
  • 5
  • 27
  • 28
0
votes
1 answer

Basic Math program throws system null exception

Here is a basic math programm in which all I simply want to do is save these values num1 and num2 into the list saved within the class. This keeps throwing this error when the program gets to the line in which it is…
0
votes
1 answer

NullReferenceException vb Array

I always get NullReferenceException error when I try to run the this code: Dim startx As Int64 Dim starty As Int64 Dim count As Int64 = 0 Dim Position() As Point startx = 15 starty = 18 Position(count) = New Point(startx, starty) Can someone tell…
Rnd661
  • 1
0
votes
0 answers

Why am i getting a NullReferenceException in my PlayerController Script

Im following Brackeys video on NavMesh movement, and i got this error right at the very end. I cant work out why, the only thing i have that is not initialized is Vector3.zero, but Brackeys does it in his video and it works fine. The error i get is…
0
votes
1 answer

Unity error. NullReferenceExeption when adding instance into static list through button click method

So basically. I was working on Model in my game and after I finished it I wanted to test it out. Guess what. It didn't work and my teacher said, that he doesn't see any mistake. There are 3 classes involved in this problem. 1st class - nothing…
0
votes
0 answers

System.NullReferenceException : entity was null

I'm working under Visual Studio 2017. I want to retrieve the comments the user is typing in the form. In order to do so, if there are no datas in the db, I'm using a post request, and if there are datas I'm using a put request. The post is working,…
0
votes
1 answer

Switching to the default frame throws an NullReferenceException

I am working one some web tests using selenium and Nunit in C#. I am currently having some issues with Iframes. In one of my methods I would like to return to the default frame, but using driver.SwitchTo().DefaultContent(); throws a…
Jaco9307
  • 13
  • 7
0
votes
1 answer

debugging resource strings are unavailable often the key and arguments silverlight

My client on production is facing this issue 'debugging resource strings are unavailable often the key and arguments' in Silverlight. Bit, when I am trying to run code locally it is running successfully. But, on production, we are facing this issue.…
0
votes
1 answer

c# wpf mvvm prism regionamanger property is null in Bootstrapper

Im trying to create a new WPF MVVM prism project, but when i try to add view to my region in shell there is a null reference exception for RegionManager property. Can anybody help me ? here is my code: class Bootstrapper : UnityBootstrapper …
Genna
  • 1
  • 5