Questions tagged [argumentnullexception]

[MSDN] The exception that is thrown when a null reference is passed to a method that does not accept it as a valid argument.

MSDN ArgumentNullException is thrown when a method is invoked and at least one of the passed arguments is null but should never be null.

ArgumentNullException behaves identically to ArgumentException. It is provided so that application code can differentiate between exceptions caused by null arguments and exceptions caused by arguments that are not null. For errors caused by arguments that are not null, see ArgumentOutOfRangeException.

ArgumentNullException uses the HRESULT E_POINTER, which has the value 0x80004003.

For a list of initial property values for an instance of ArgumentNullException, see the ArgumentNullException constructors.

166 questions
3
votes
1 answer

Serialization of ArgumentNullException to Json

When serializing a System.ArgumentNullException to JSON using JSON.NET, part of the message appears lost: var json = JsonConvert.SerializeObject(new ArgumentNullException("argument", "Some…
Eric Patrick
  • 2,097
  • 2
  • 20
  • 31
2
votes
2 answers

MSTest Unit Test asserting specific exception messages

I'm writing my first Unit test for very small project. Here the expected result and result both return a ArgumentNullException but the test still fails. Any idea why? [TestMethod] public void…
2
votes
1 answer

C# ArgumentNullException type or namespace could not be found. VS Code

Part Of My Code: public void Move(Point newLocation) { if (newLocation == null) throw new ArgumentNullException("newLocation"); Move(newLocation.X, newLocation.Y); } I get this as a Error: The type or…
user12167391
2
votes
0 answers

Random occurence of System.ArgumentNullException in Windows Service

I have been facing this weird issue with my WCF service which is already Deployed. It has been set to automatic restart in case of errors. I have been observing my service is getting stopped randomly. And I don't get any log of the same. It has been…
2
votes
2 answers

streamReader ArgumentNullException

Hey there, I have a program that uses a sql express local DB. I want to be able to update that DB using the program to run the necessary scripts. A text files has been added as an embedded resource to the project (VS2010), and the file contains…
dave k
  • 1,329
  • 4
  • 22
  • 44
2
votes
4 answers

System.NullReferenceException When checking if != null

I'm using an ASHX handler, i want the handler to check if Session != null. if (context.Session["Username"] != null) And i get this error pointing this line: System.NullReferenceException: Object reference not set to an instance of an…
Danpe
  • 18,668
  • 21
  • 96
  • 131
2
votes
0 answers

Using Null-Propagation operator with null-coalescing-operator to throw a null exception

I'm trying to get the value that is null in my chained variable I've created three scripts. Level1, level2, level3. Level 1 has a public variable of level2, level2 has public variables of level3 and sets up the object variable in level 3. Using…
2
votes
2 answers

ArgumentNullException in C# setter

I´ve got the following code: private string _email; public string email { get { return _email; } set { try { MailAddress m = new MailAddress(email); this._email = email; } catch…
stack man
  • 2,303
  • 9
  • 34
  • 54
2
votes
2 answers

How do I fix this ArgumentNullException in int.Parse?

This is the .cs file runs fine in Mono: using System; public class HelloWorld { static public void Main () { Console.WriteLine("Enter a number"); int UserNumber = int.Parse(Console.ReadLine()); Console.WriteLine("Your number…
Jaidyn Belbin
  • 475
  • 2
  • 7
  • 17
2
votes
0 answers

LINQtoCSV cannot assign IEnumerable to List - ArgumentNullException was unhandled

I have csv file that I read and store in IEnumerable data_values. The only problem is that when I want to read it with MessageBox.Show() then it throws ArgumentNullException was unhandled. I tried to do it like if(data_values != null) but it doesn't…
2
votes
2 answers

ArgumentNullException using a list

I am developing an MVC 4 C# internet application. I have a MapLocationCompany class as well as a MapLocation class. I am after each MapLocationCompany object to have a list of MapLocation objects. Here is my current code: public class…
Garry
  • 1,251
  • 9
  • 25
  • 45
2
votes
1 answer

SQL PL/SQL user defined multiple exception error handling (null)

I'm trying to write a stored procedure that will have 2 exception errors. Create table Employee (emp_num varchar(10) primary key, emp_name varchar(10), DOB date, job_title varchar(15), marriage_date date, spouseid varchar(10) references…
2
votes
1 answer

vb.net image save to memory stream results in an ArgumentNullException

In VB.NET I have the following function that allows me to calculate a hash for an image I have not yet saved to a file : Public Function pictureHash(ByVal image As System.Drawing.Image) As String Try If image Is Nothing Then Return Nothing …
Joel
  • 115
  • 1
  • 2
  • 10
2
votes
1 answer

ArgumentNullException when DataBind() called on DropDownList

When I call DataBind() on a DropDownList in ASP.NET 4, it's throwing an ArgumentNullException: System.ArgumentNullException: Value cannot be null. Parameter name: container at System.Web.UI.DataBinder.GetPropertyValue(Object container, String…
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
2
votes
0 answers

AdventureWorks delete from database failed tests

I have the below tables from AdventureWorks database which you can see my model here: , This is my repository service public class EmployeeRepository : IEmployeeRepository { private AdventureWorksEntities dataBaseContext = new…
Konrad
  • 726
  • 4
  • 17
  • 33
1
2
3
11 12