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

DataTable is empty in release mode, but not in debug mode although I initialized it

My code works in debug mode, but in release mode I get a System NullReference Exception for the MTable in line 6 and I don't know the reason. In debug mode I have access to the data. Dim myregex As Regex = New Regex("A[1-6]|A[A-M]") Dim MTable As…
user11613271
0
votes
0 answers

How to fix a "Null Reference Exception" in c#

I am currently assigning an Event Handler to an Event, but I did need to pass one other argument to know what produced this event. It is in a function to set up a XAML file. I did something like that : chart[i].PaintSurface += (sender, e) =>…
0
votes
2 answers

how to bind dictionary to Listview itemsource

I have a ListView shown below. How can I bind dictionary to ListView Itemsource so that my label as key and ENtry has value? I don't know How to proceed further I tried with this but I am getting null reference exception
0
votes
2 answers

Collision Detection/Remove object from ArrayList

I am currently trying to test collision between a falling object and a box. I understand basic collision detection, but my problem here is that I have to test it for an indefinite number of falling objects. When these objects(blossoms) are created,…
Hani Honey
  • 2,101
  • 11
  • 48
  • 76
0
votes
0 answers

How to merge structure of two DataTables into one c#?

I have two data tables and want merge columns and create as third table. Do not want to lose ExtendedProperties so not Selecting DataColumn.ColumnName and adding as columns. Code: DataTable dt1 = new DataTable(); dt1.TableName =…
Prem
  • 316
  • 1
  • 5
  • 23
0
votes
2 answers

unable to pass string from user control to richtextbox located in a flowlayoutpanel in form1

Form1 has a richtextbox1 and UserControl1 has a button1 Form1 loads and adds an instance of UserControl1. I click the button and the richtextbox prints "hello" //UserControl1.cs public partial class UserControl1 : UserControl { public…
0
votes
1 answer

"Object reference not set to an instance of an object" in Xamarin.android c#

I was just trying to make a simple app with Xamarin.android from the tutorial shown https://learn.microsoft.com/en-us/learn/modules/create-a-mobile-app-with-xamarin-forms/5-exercise-create-phone-number-translator-app But when I build it,…
0
votes
1 answer

Can the Kotlin Compiler Require non-null assertion?

Can the Kotlin Compiler require non-null assertions? for example. I'm getting a query result from JOOQ, and the relting type is Record!. But the compiler allows me to access members without checking for null. val orderResult =…
rharriso
  • 1,151
  • 10
  • 11
0
votes
1 answer

There is a null reference exception to merge two data table

I'm going to call data from the DAL, send it to the BLL, and I'll give it to XtraReport. The scenario is as follows: In the DAL: public static List GetAllProductList() {             try             {                 return…
Piroozman
  • 29
  • 9
0
votes
1 answer

Can't get length of empty array without null reference exception

EDIT: I already know what a null reference exception is. What I can't figure out is how to set up my code so that it reads the length of an empty array without throwing a null reference exception. I have a form that needs to add an item to a set of…
Ethan Malloy
  • 555
  • 1
  • 4
  • 16
0
votes
2 answers

determine the cause of this error, Checkbox c#

hi all i'm having a hard time trying to understand why some code that i have crash. The problematic instructions are like this: First try: bool aers = vm_SessionTab.IncrementalConstruction; // != null bool chua =…
mjsr
  • 7,410
  • 18
  • 57
  • 83
0
votes
0 answers

Linq query throws NullReferenceException

Consider the following two pieces from an XSD. 1.
Rico Strydom
  • 537
  • 1
  • 6
  • 26
0
votes
1 answer

How to fix RuntimeBinderException when using dynamicJsonObject.getDynamicMemberNames()

I have found the solution to this question while writing it, but I'm still posting it so that if somebody has this problem in the future, they can find this This question is related to this question as in this is my latest attempt at solving my…
0
votes
1 answer

null reference exception when i delete item from sync realm database in xamarin

I got a null reference exception after I delete any item from the sync realm database . the item is deleted from the database but it throws the exception and craches I don't know why it throws this exception or where is the null object . but when I…
maria nabil
  • 141
  • 3
  • 9
0
votes
2 answers

MVC Membership Problem

Almost every time I run my MVC app, it stops with errors before getting to the home page. UPDATE: Here's the latest code: public class RequireLoggedIn : ActionFilterAttribute { public override void…
user704119