argumentnullexception

ArgumentNullException on changing frame

岁酱吖の 提交于 2019-12-22 04:56:26
问题 So I'm trying to change frames in a windows 8 app. I tried following the tutorial at this page, but I keep getting the same error. I'm getting an ArgumentNullException on the line: frameState[_pageKey] = pageState; in the LayoutAwarePage.cs class, in the OnNavigatedFrom method. Now I'm not sure why I get this error, because I feel that there is nothing that could cause it in my code. My button onclick function has this code: DateTime chosenDateTime = new DateTime(year, month, day, hours,

How do I fix this ArgumentNullException in int.Parse?

孤者浪人 提交于 2019-12-20 03:27:05
问题 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 is: " + UserNumber); } } I opened this Test.cs file in Xamarin, which worked properly. Then I choose 'Run' > 'Start Without Debugging' and these errors pop up in the display panel: Enter a number Unhandled Exception: System.ArgumentNullException: Argument cannot be null.

Why does this string extension method not throw an exception?

痴心易碎 提交于 2019-12-18 10:09:37
问题 I've got a C# string extension method that should return an IEnumerable<int> of all the indexes of a substring within a string. It works perfectly for its intended purpose and the expected results are returned (as proven by one of my tests, although not the one below), but another unit test has discovered a problem with it: it can't handle null arguments. Here's the extension method I'm testing: public static IEnumerable<int> AllIndexesOf(this string str, string searchText) { if (searchText =

Windows Phone link from Tile error

£可爱£侵袭症+ 提交于 2019-12-13 04:23:48
问题 I have a list of theaters and I created a secondary tile from my application to navigate directly to specific theater. I pass the id of the theater in query string : I load the theaters from a WCF service in the file "MainViewModel.cs" In my home page, I have a list of theaters and I can navigate to a details page. But when I want to navigate from the tile, I have an error... The Tile : ShellTile.Create(new Uri("/TheaterDetails.xaml?selectedItem=" + theater.idTheater, UriKind.Relative), tile,

An unhandled exception of type 'System.ArgumentNullException' occurred in MonoGame.Framework.dll

雨燕双飞 提交于 2019-12-11 20:14:45
问题 I'm currently trying to create a simple game using MonoGame. The problem I'm currently facing is that sometime(like half of the time) my code runs without problem. But there's time when it throw me this exception: An unhandled exception of type 'System.ArgumentNullException' occurred in MonoGame.Framework.dll Additional information: Value cannot be null. So my question here is how do approach this kind of problems as it doesn't happen all the time? I've tried cleaning my solution. But

System.NullReferenceException When checking if != null

馋奶兔 提交于 2019-12-10 18:03:19
问题 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 object. What's the problem? 回答1: if (context.Session["Username"] != null) Does your handler implement IRequiresSessionState? Otherwise Session might not be available. From MSDN: Specifies that the target HTTP handler requires read and write access to session

Why is EditorFor in my ASP.NET MVC 2 application throwing ArgumentNullException?

家住魔仙堡 提交于 2019-12-02 15:51:13
问题 I have a weird problem with EditorFor in one of my views. The following code throws an ArgumentNullException. <%: Html.EditorFor(x => x.Name) %> However, the following code is fine. <%: Html.TextBoxFor(x => x.Name) %> Model.Name is a string variable - and it's set. EditorFor works in another view - until this view crashes, at which point then I have to restart the development web server (Cassini) or all the EditorFor calls crash with the same message. I ran a test with the MVC 2 source,

Why is EditorFor in my ASP.NET MVC 2 application throwing ArgumentNullException?

那年仲夏 提交于 2019-12-02 09:55:07
I have a weird problem with EditorFor in one of my views. The following code throws an ArgumentNullException. <%: Html.EditorFor(x => x.Name) %> However, the following code is fine. <%: Html.TextBoxFor(x => x.Name) %> Model.Name is a string variable - and it's set. EditorFor works in another view - until this view crashes, at which point then I have to restart the development web server (Cassini) or all the EditorFor calls crash with the same message. I ran a test with the MVC 2 source, hoping I could get some insight, but that worked OK! Presumably the MVC 2 RTM source on there should be the

How do I fix this ArgumentNullException in int.Parse?

爷,独闯天下 提交于 2019-12-02 04:32:18
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 is: " + UserNumber); } } I opened this Test.cs file in Xamarin, which worked properly. Then I choose 'Run' > 'Start Without Debugging' and these errors pop up in the display panel: Enter a number Unhandled Exception: System.ArgumentNullException: Argument cannot be null. Parameter name: String at System.Number.StringToNumber (System.String str, NumberStyles options, System

Create class instance from string

泪湿孤枕 提交于 2019-12-01 06:28:59
I have a C# method which creates a new instance of a class from a string, however, I get an error when running the code. obj = (ClassX)Activator.CreateInstance(Type.GetType("classPrefix_" + className)); ArgumentNullException was unhandled Value cannot be null Parameter name: type Any help on this error would be appreciated. You may need to use the assembly qualified name as the argument to Type.GetType eg AssemblyName.Namespace.ClassName MSDN Doc on assembly qualified names You may just be missing the namespace from the classname Works for me: class ClassX {} class classPrefix_x : ClassX {}