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
4 answers

How to propogate null instance in C#/MVC without If/Else or Try/Catch?

I have an entry in Razor View which is
  • @* stock is a JObject which can contain or cannot contain ["images"]*@ Irrespective of location of null occurence, how to get the final string data-img-url="".…
  • Flood Gravemind
    • 3,773
    • 12
    • 47
    • 79
    0
    votes
    2 answers

    Why am I getting this NullReferenceException?

    I'm working on a project that involves some home-made (de-)serialization code, and I have run into some issues with the deserializing of a List. The following code is throwing a NullReferenceException on the second line, even though the var list is…
    Aistina
    • 12,435
    • 13
    • 69
    • 89
    0
    votes
    0 answers

    Getting Null Reference Exception while accessing columns from other tables

    I am trying to do CRUD operations in c# using Linq on Products of the NWTraders Database. While Adding a new product, I am trying to display Supplier Name and Category Name instead of the Supplier ID and Category ID(which are foreign keys of the…
    Student
    • 11
    • 1
    0
    votes
    2 answers

    Null Reference Exceptions depending on what solution project is loaded into?

    Okay, this problem is a bit odd. I have an application built in VS2010 that runs fine in it's own solution. However, if I load the project into a bigger solution (with 110+ projects), I start getting NullReferenceExceptions, and sometimes if I…
    Saggio
    • 2,212
    • 6
    • 33
    • 50
    0
    votes
    0 answers

    DTO returns null when called from a Rest client using spring boot

    This is making a spring boot project to maintain the MVC architecture and as well being RestFul. There is a project that is fully working properly using the MVC architecture, I'll like to make it work as well by being called from a Rest client.…
    ken4ward
    • 2,246
    • 5
    • 49
    • 89
    0
    votes
    1 answer

    ajax method to delete the item from the list and get error in the model

    this is my wiew****I list my my model here @model WebApplication2.Models.NewsListQueryModel
    Id…
    0
    votes
    1 answer

    String interpolation between if statements

    So i have this speech recognition code with a few commands that trigger animations in C# and Unity. So instead of having to activate each animation then deactivate it before switching to another animation I wanted to make it so that whatever…
    0
    votes
    1 answer

    Issue getting NullReferenceException using Http with jwt Xamarin Forms Android

    So my code works in PostMan querying the api to populate a listview locally in my Android app. But when I run it from within the app, I get NullReferenceException on the line "Items.Clear() in ShipViewModel.cs I tried hardcoding the address rather…
    0
    votes
    1 answer

    Silverlight control in XAML is null at runtime

    I've created a silverlight app with a DeepEarth map control on it. Here is my base XAML
    mcintyre321
    • 12,996
    • 8
    • 66
    • 103
    0
    votes
    1 answer

    NullReferenceException when listing IdentityRoles in web page in asp.net using Code First

    I want to retrieve data from IdentityRole and show it in a web page. I have seed the IdentityRoles detailes before and I'm referencing ProjectRole Model to list it down in a web page. Below is my controller page. private ApplicationDbContext…
    shamila
    • 1,280
    • 6
    • 20
    • 45
    0
    votes
    0 answers

    Html Agility Pack gives NullReferenceException for items that exist

    I'm getting started with Html Agility Pack but I'm struggling with it throwing a NullReferenceException for items I know for a fact exists. For example, take this code: doc.DocumentNode.Descendants("div").ToList()[2] This returns a valid HtmlNode…
    TheHvidsten
    • 4,028
    • 3
    • 29
    • 62
    0
    votes
    0 answers

    Convert Bitmap to bytes return null when executing on build

    I have a pretty simple piece of code that takes a ScreenShot and then convert it to bytes to make screen sharing. It works well when using it on Unity but as soon as I try on a built .exe. I have a NullPointerException even though none of the…
    0
    votes
    1 answer

    Unable to Check Permission of a SharePoint Group

    I tried to use examples from the net to check if a group has a specific permission in my SP site. Below is my code snippet: if (roleAssignment.Member is SPGroup) { //displays as 1 …
    gymcode
    • 4,431
    • 15
    • 72
    • 128
    0
    votes
    1 answer

    How to push objects onto stacks?

    sub main() dim menuhistory as stack(of menu) dim currentmenu as menu dim apple as new menu("fruit") currentmenu = apple menuhistory.push(currentmenu) public class menu menutext as string Public Sub New(ByVal input As String) …
    Peter Benson
    • 15
    • 1
    • 5
    0
    votes
    0 answers

    Unit Testing: Null Reference Exception when doing FindAll on List with Predicate

    I have a method in an abstract class FakeEntityBaseRepository, called FindBy with the following code: public IEnumerable FindBy(Expression> predicate, params string[] includeProperties) { Func func =…
    user11885952