nullreferenceexception

NullReferenceException in EntityFramework, how come?

痴心易碎 提交于 2019-12-25 02:53:58
问题 Take a look at this query: var user = GetUser(userId); var sessionInvites = ctx.SessionInvites .Include("InvitingUser") .Include("InvitedUser") .Where(e => e.InvitedUser.UserId == user.UserId) .ToList(); var invites = sessionInvites; // Commenting out the two lines below, and it works as expected. foreach (var invite in sessionInvites) ctx.DeleteObject(invite); ctx.SaveChanges(); return invites; Now, everything here executes without any errors. The invites that exists for the user are being

NullReferenceException: Object reference not set to an instance of an object #2

自作多情 提交于 2019-12-24 23:07:42
问题 Error shown on the website. Im using asp net visual C# webform, access data source (MS access) When I click on Add to Cart button on productdetails.aspx Line 41: int intOrderNo = (int)Session["sOrderNo"]; Line 42: string strUnitPrice = (string)Session["sUnitPrice"]; Line 43: decimal decUnitPrice = decimal.Parse(strUnitPrice); For myOrder table in Ms Access There is oOrderNo, oDate, oUserName, oPaymentMode, oStatus, protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { //

Problems with WP8 Slider

最后都变了- 提交于 2019-12-24 20:28:30
问题 My XAML: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="auto"/> </Grid.ColumnDefinitions> <Slider Name="sldLength" Margin="0 0 0 0" Grid.Column="0" Minimum="5" Maximum="30" SmallChange="1" LargeChange="1" Value="10" ValueChanged="sldLength_ValueChanged"/> <TextBlock Name="tblLength" Margin="0 10 5 0" Text="10" Grid.Column="1" FontSize="{StaticResource PhoneFontSizeMediumLarge}"/> </Grid> My Code begind: private void sldLength_ValueChanged(object sender,

string.IsNullOrEmpty() Doesn't Seem to Work on a String within a Class within a Class

夙愿已清 提交于 2019-12-24 03:07:51
问题 First off, I think I know what's going on, but I thought I'd bring this issue up here for some discussion and see if anyone has an "answer" to this other than what I'm thinking. Because, it doesn't completely make sense to me. What I found is that when creating a error log for exceptions, I was doing this and it wasn't working: catch( Exception ex ) { LogException( ex.Message ); if ( !string.IsNullOrEmpty( ex.InnerException.Message ) ) { LogInnerException( ex.InnerException.Message ); } } and

Ironpython: Function works in CPython, mysterious null pointer exception in IronPython

瘦欲@ 提交于 2019-12-23 15:39:58
问题 I'm trying to do something that seems very simple, and falls within the range of standard python. The following function takes a collection of sets, and returns all of the items that are contained in two or more sets. To do this, while the collection of sets is not empty, it simply pops one set out of the collection, intersects it with the remaining sets, and updates a set of items that fall in one of these intersections. def cross_intersections(sets): in_two = set() sets_copy = copy(sets)

WPF ObservableCollection.Remove throws NullReferenceException

末鹿安然 提交于 2019-12-23 14:02:21
问题 The code that invokes the remove operation normally works, this is the first time that I've received the NullReferenceException. I'm trying to figure out whether I might be doing something wrong and whether the exception can be avoided to make the software more bullet proof. The, relatively, big number of System.Windows.DescendentsWalker`1.WalkFrameworkElementLogicalThenVisualChildren calls seem a bit funky too. Any help will be appreciated. OS: 6.1.7600.0 .NET: 4.0.30319.225 Stack: at System

Null reference exceptions during Base64 deserialization (C#)

你说的曾经没有我的故事 提交于 2019-12-23 12:47:23
问题 I am using the following methods to serialize and deserialize .NET objects: public static string SerializeToBase64(object data) { var stream = new MemoryStream(); var formatter = new BinaryFormatter(); formatter.Serialize(stream, data); stream.Position = 0; return Convert.ToBase64String(stream.ToArray()); } public static object DeserializeFromBase64(string data) { var stream = new MemoryStream(Convert.FromBase64String(data)); stream.Position = 0; var formatter = new BinaryFormatter(); return

Should I null-protect my F# code from C# calls

喜欢而已 提交于 2019-12-23 12:08:33
问题 I am writing a library in F#, with some interfaces and base classes that are publicly visible. Generally, I avoid specifying [<AllowNullLiteral>] on my custom types as this complicates the validation logic in my F# code (see this nice post for goods and bads of null handing in F# to get a picture ), and also, F# does not initially allow null for F# types. So, I validate for nulls only for types that accept the null value as valid. However, an issues arises when my library is used from another

System.NullReference Exception occurred in App_Web_XXX.dll - Error in Partial View

可紊 提交于 2019-12-23 10:06:56
问题 I'm getting this error, with a random string in the dll name, when landing on one of my MVC pages. A first chance exception of type System.NullReferenceException occurred in App_Web_cjmhrrqn.dll. Additional information: Object reference not set to an instance of an object. on another page, I get similar when hitting the first line of code on the page, not matter what it is: A first chance exception of type System.NullReferenceException occurred in App_Web_register.cshtml.5f83eb8c.gq-8jyy8.dll

System.NullReference Exception occurred in App_Web_XXX.dll - Error in Partial View

流过昼夜 提交于 2019-12-23 10:05:20
问题 I'm getting this error, with a random string in the dll name, when landing on one of my MVC pages. A first chance exception of type System.NullReferenceException occurred in App_Web_cjmhrrqn.dll. Additional information: Object reference not set to an instance of an object. on another page, I get similar when hitting the first line of code on the page, not matter what it is: A first chance exception of type System.NullReferenceException occurred in App_Web_register.cshtml.5f83eb8c.gq-8jyy8.dll