2,779 questions
2
votes
1
answer
80
views
Code triggers unexpected null value in Firestore data call
I am working in Flutter on a web app. I am not a coder and I'm having issues with a very simple app that changes a color based on a boolean stored in Firestore. I'm seeking an understanding of how to ...
2
votes
1
answer
46
views
Remove-IISConfigCollectionElement causes NullReferenceException
I am developing a PowerShell script to modify customHeaders in my website's web.config file, specifically the Content-Security-Policy header. I'm doing this with a script for 2 reasons:
For my ...
2
votes
1
answer
147
views
NullReferenceException when checking if the Model is null on a Razor Page
I have a situation where I am getting a NullReferenceException when I am checking a model (not a property) to see if it is null. Follow these steps to re-create the issue yourself.
Create a brand new ...
0
votes
0
answers
46
views
System.Data.Entity.Infrastructure.CommitFailedException
System.Data.Entity.Infrastructure.CommitFailedException: An error was reported while committing a database transaction but it could not be determined whether the transaction succeeded or failed on the ...
0
votes
1
answer
84
views
In a WebForms application, newly added control is null at runtime on published site but not in local debugging
I just added a new control in an existing page aspx file, assuring the validity of the markup and code itself by running it locally in debug shows correctly the new control and behaviors in page.
But ...
0
votes
1
answer
35
views
Value of a variable in a script, on a GameObject in an array? [duplicate]
My first question here. I'll try to be clear :)
Is there a way to get the value of a variable in a script, on a GameObject in an array?
I have an array of GameObjects, on which each of them has the ...
1
vote
0
answers
92
views
C# ASP.NET GridView - Row_Updating issues trying to get values from cells in the Gridview with NullReferenceException
There are 2 parts to my question. Please bear with me... just learning this stuff.
I have a GridView that allows editing, which will update a database table. Issue #1 is that I cannot seem to get the ...
0
votes
0
answers
23
views
Unity Null reference exception when referring to Serialized GameObject in another class [duplicate]
Edit: I know this looks like a duplicate, but I understand that a Nullreference exception happens as I access an object that hasn't been set, or is null. However, I simply don't understand why any of ...
0
votes
0
answers
16
views
Why is the debugger in universal windows app showing modelgen is null
I was running the code for a universal windows app when the debugger raised:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
modelGen was null.
The code is :
//...
-1
votes
1
answer
101
views
How can I tag a value as not expected to be null?
I have a function that's correctly specified as returning a potentially-null object. My code calls that function but in a way where it isn't going to return a null.
MyClass? MyFunction(string x);
/* .....
1
vote
1
answer
530
views
Unity - Why is my Singleton throwing a NullReferenceException when I re-load the scene?
I am facing an issue with a NullReferenceException in my code. I've created a LevelManager script to manage the different scenes of my game. Inside this file ScoreKeeper object is called. This ...
0
votes
1
answer
48
views
EcoProject1EcoSpace suddenly not instantiating in VS2022 (MDriven Framework, 4.8.1)
OK, so I solved this problem (runtime crash due to incompatible types recognized by Eco's TypeLibrary-scan).
Solution: I removed Rhinol3D classes from Eco method signature parameters, and then ...
2
votes
1
answer
62
views
C# - Creating a query in a SQL DB with EntityFrameWork - ERRO -> Value cannot be null. (Parameter 'source')
I'm trying to create the following query in C# with EntityFrameWork:
SELECT * FROM Companies WHERE Name LIKE '%(searchValue)%';
This is the table sample:
Company class:
public class Company {
...
2
votes
0
answers
350
views
NullReferenceException is thrown when reloading Blazor app with NavigationManager
I'm struggling with finding the reason of exception which is thrown after the entire page is reloaded.
It's a Blazor application (server side, .NET 8). In the header, there is a select list which ...
1
vote
2
answers
197
views
unhandled System.NullReferenceException: on debug clean .net coreweb api / exception at System.Buffer.Memmove(Byte& dest, Byte& src, UIntPtr len)
i have last vs 2022 17.10.5 no updates possible
when i do new > asp.net core web api > some location >
create
and hit debug with no change
then it open browser with url https://localhost:...
1
vote
1
answer
88
views
Dereference of a possibly null reference when using Extension Methods with Annotation
I have the following extension method for IsNotNull and it works fine but I get warning when using it that there may be a null reference and I am trying to figure out how to remove that warning ...
1
vote
2
answers
99
views
Layout Cascading Parameter is null inside pages - Blazor Server
I am trying to pass the layout as a cascaded parameter to the page that uses the layout. The issue I am facing is that the layout cascaded parameter in the page is always null.
Here is the code I am ...
0
votes
0
answers
31
views
I don't know how to fix this NullReferenceException in C# [duplicate]
I'm programming a Text Adventure RPG in C# for a university project and it's due on Sunday. Now i've encountered this fatal exception that doesnt let me even execute the program.
class Program {
...
1
vote
0
answers
38
views
A non-null variable results me to NullReferenceException [Unity] [duplicate]
I've been on Unity for a very long time, yet I've come across the most common error.
I made a script to create a ship components store from a list of ScriptableObjects.
Here's the ScriptableObjects:
...
2
votes
1
answer
67
views
Why is object array null later in the script even after confirming its not null after initialization
The title. there are no mentions of the spriterenderers or array anywhere else in the program
SpriteRenderer[,] Renderer = new SpriteRenderer[8,8];
void Awake()
{
if (D)
{
...
0
votes
1
answer
64
views
Application runs perfectly in Visual Studio, yet when the executable runs it throws NullReferenceException. File reading issue?
I have written a C# application in Visual Studio (using Avalonia, irrelevant for this question).
It runs perfectly in Visual Studio, yet when I try and run the executable, it throws a ...
0
votes
0
answers
117
views
NullPointerException: Attempt to invoke virtual method 'long SecuGen.Driver.SmartCapture3Fdu05.Start(int, boolean)' on a null object reference
I developed an application for **android **where i am getting Finger Print using **SecuGen **Pro 20 device.
Samsung device capture the finger print image. But other device can not capture image (such ...
1
vote
0
answers
115
views
How to fix Image variable that is null during playtesting?
So currently I’m making inventory functions for my Michael game. I was making a script called RespawnItem.
public class RespawnItem : MonoBehaviour
{
//----PUBLICS----//
public PlayerCollectingSystem ...
0
votes
0
answers
30
views
NullReferenceException on ldarg.1 instruction [duplicate]
We have a C#/.NET application running as a Windows Service. Infrequently, it logs several entries of the following form in the Windows Event Viewer.
Log Name: Application
Source: Windows Error ...
0
votes
1
answer
54
views
nullreferenceexception from ExecuteScalar()
I really don't know what to write here. I was just coding and this stuff happened.
connection.Open();
SqlCommand cmd = connection.CreateCommand();
cmd.CommandText = "select count(*) from ...
0
votes
0
answers
93
views
WinForms: Reference to UserControl returns null, Forms designer adds bad code to InitializeComponent method
In this class library, there are several UserControls that get loaded and unloaded from a container Panel depending on what functionality is required. These UserControls contain docked panels that ...
0
votes
0
answers
84
views
ListView.Items(0),Selected error System.nullreferenceexception
I'm trying to debug a program which uses a ListView to create a list of icons for files stored in a DB. I got the log of an exception stating System.nullreferenceexception: 'object reference not set ...
0
votes
0
answers
19
views
NullReferenceException: Object reference not set to an instance of an object in Unity cause by coding [duplicate]
ansNum = Random.Range(0, ans.Count);
ADisplay.AnsA = ans[ansNum];
ans.RemoveAt(ansNum);
ansNum = Random.Range(0, ans.Count);
ADisplay.AnsB = ans[ansNum];
ans.RemoveAt(ansNum);
...
0
votes
0
answers
35
views
What parameter should I specify for Properties.Settings.Default.History so that it doesn't give an error with Null? [duplicate]
I create the "History" parameter through the project properties
and I'm trying to put a value in that parameter and save it:
Properties.Settings.Default.History.Add("00:30");
...
1
vote
1
answer
48
views
Why throwing a Null reference In Razor component production?
I have a test code
@page "/admin/userInfo"
@page "/admin"
@inherits OwningComponentBase<UserManager<IdentityUser>>
@inject AuthenticationStateProvider ...
-2
votes
1
answer
61
views
Why do I get a null here?
So this piece of code
public boolean getBoolean(Integer Id) {
return Optional.of(Store.getMagazin(Id))
.map(MagazinDO::getBoolean)
.orElse(Boolean.FALSE);}
returns a null while ...
0
votes
0
answers
21
views
Changing difficulty settings in an Unity Pong game [duplicate]
I get "NullReferenceException: Object not set to an instance of an object" error, while trying to get a value from another script.
//first script
public class Easy : MonoBehaviour
{
...
0
votes
1
answer
76
views
ASP.NET controls not rendering in runtime (are null) after AJAX call
I have the following aspx panel:
<asp:Panel ID="EndPanel" runat="server" CssClass="container" Visible="false">
<asp:Image ID="Border" ...
1
vote
1
answer
2k
views
System.TypeInitializationException - The type initializer for '<Module>' threw an exception
I have been working on an application for about two and a half years now and last month we went live and published our .NET application. The application is a WPF application that uses .NET version 5.0....
0
votes
1
answer
206
views
A weird NullReferenceException from J2N HashSet AddInNotPresent method that is called by Lucene.Net
I post part of the stack trace. This exception doesn't happen regularly and is hard to replicate. But it usually occurs after getting back from its IIS process idle.(Run it first, do nothing for a ...
0
votes
0
answers
35
views
Can an implicit interface cast cause null with a COM object?
I got an intermittent ArgumentNullException I can't understand.
the code looks something like
COMRow row = GetCOMRow();
DoSomething1(row);
DoSomething2(row);
DoSomething3(row);
...
// DoSomething ...
1
vote
0
answers
1k
views
Encountered infinite recursion while looking up resource 'Arg_NullReferenceException' in System.Private.CoreLib
My program was developed in .Net 7 (VS 2022) and running on non-English Windows 10 (x64). Most of the time my program works normally. However, the following error (in Event Viewer) was thrown ...
0
votes
2
answers
95
views
C# null checking extension method on sub-object does not work [duplicate]
I have a null-checking extension method
public static IEnumerable<T> OrEmptyIfNull<T>(this IEnumerable<T> source)
{
return source ?? Enumerable.Empty<T>();
}
which is nice ...
0
votes
1
answer
64
views
Null reference but database has data
I have a problem for showing Level and Statues of course in course View enter image description here.
Here is my problem and the database does have data, but in add course service, it returns null in ...
0
votes
1
answer
53
views
iText7 Array of Tables
the code snippet will compile but when run a NullReferenceException is thrown. It says "object not set to an instance of an object". The code is created using .NET Core 3.1 on VS2019.
I ...
0
votes
1
answer
83
views
asp.net find control inside runat div
I have this div in my markup
<form id="form1" runat="server">
<div class="mt-5">
<div id="d" runat="server"></div>
...
1
vote
1
answer
131
views
Join of Two Tables Not Working on Razor Page
I have a report page that I am trying to create on a Razor page app and I cannot get it to work. I have a similar working app and cannot see where I am doing anything differently, but must be missing ...
0
votes
1
answer
29
views
Nullable object must have a value in Context of Count Expression
I am receiving this error on a report page on my asp.net app. I have looked at the other answers to questions asked about this error, but am still unable to understand how to resolve it.
I am ...
1
vote
1
answer
594
views
Exception thrown within lambda not caught by catch block [duplicate]
I've seen a few questions about lambdas and exceptions, but I still don't understand the behavior I'm seeing in my code.
class MyObj
{
public object Prop1 { get; set; }
...
-3
votes
1
answer
322
views
Converting null literal or possible null value to non-nullable type even if already checked for null [duplicate]
can anyone tell why the compiler is throwing the warning even if i checked everthing for null??
// check if non default accent color is selected
var accCol = await LocalSorage.GetItemAsync<string&...
2
votes
3
answers
1k
views
NullReferenceException using dependency injection in a .NET MAUI app
I am having a strange NullReferenceException error when using dependency injection in my .NET MAUI 7 app. The API call to my API/token login URL works perfectly when I instantiate a new HttpClient for ...
1
vote
0
answers
80
views
Test Class runs before @beforeSuite Class which causes NullreferenceException on Webdriver
I am new to selenium and I am trying setup a Automation framework, I have two classes one for Webdriver (Base class) initialization and second is to run testScripts I have Marked the Webdriver ...
1
vote
0
answers
156
views
ASP.NET Core MVC: asp-for Tag Null Property Behavior - VS2017 vs VS2022
I created a web app using ASP.NET Core MVC 2.0 in 2019 using Visual Studio 2017. I'm trying to update it now, and nowadays I also have Visual Studio 2022 installed, so I'm trying to use VS2022 to ...
1
vote
0
answers
144
views
How/why does ModelState throw System.NullReferenceException when being checked for null?
UPDATE: To avoid the problem, I tried explicitly checking for null, thinking that surely there's no way it could possible still throw the exception.
It does.
The following line throws a System....
0
votes
1
answer
138
views
Why is session returning null even if I set a value in it?
I want to set the date into a session, but it's giving me a null value.
Here is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
...