Null Reference In Lambda Max Count?
Oct 5, 2011
Public Class Inventory
Public Property Productcode As String
Public Property lstattribute As List(Of Attribute)[code]....
I have a list of inventory items.I am trying to get the max count of attributelist in the inventory list .I used this code
oLsInventory.OrderByDescending(Function(c) c.AttributeList.Count).FirstOrDefault().AttributeList.Count
But if my attribute list null. The lambda throws null reference.Is there any way to check for null reference in lambda ? Or is there a better way to rewrite the above linq query ?
View 3 Replies
ADVERTISEMENT
Dec 15, 2011
I have a fairly simple piece of code:
Private _PurchaseDelivery as PurchaseDelivery
Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As PurchaseDeliveryItem)
[Code]....
Which is inside a class which overrides a custom list base. The code is occassionaly throwing an unhandled exception, System.NullReferenceException, on this line when used in production:
If _PurchaseDelivery IsNot Nothing AndAlso _PurchaseDelivery.DefaultSKUBinID.HasValue Then
DeafultSKUBinID is declared as an Integer? (Nullable Int) in the PurchaseDelivery class. I cannot see what might be causing this error, why would this be returning an error?
View 3 Replies
Sep 15, 2010
Can a LINQ or a LAMBDA expression be used to count the 1's in a binary string ?For example, if I convert a number to its BINARY using.>>
Dim binaryString As String = Convert.ToString( numberVariable, 2 )
1) Without using a loop such as a FOR NEXT loop, can I count the number of 1's in the STRING using LINQ or a LAMBDA expression?
2) Can I get the indexes of where the 1's are at in a collection such as a LIST using LINQ or a LAMBDA expression?I know the syntax of some LINQ expressions, however, I don't know which method may be suitable.
View 2 Replies
Sep 19, 2011
Iam maintaining a large code base I have inherited (ported from vb6 to C#.net 1.1, then to .net 2.0/c# and so on). I have this scenario.My main project references two DLLs - DLL-A and DLL-B
DLL-B references DLL-A. Both dll's and my main project are in 3 separate namespaces.
1) Are 2 copies of DLL-A being loaded in memory ? (dll ref count)
2) How do I find out how many copies of a .net dll is loaded in mem ? (which tool is normally used)
View 2 Replies
May 18, 2011
I'm trying to create a generic function to build a Linq expression from a list of Telerik grid filters. I'm trying to stay clear of dynamic Linq. Because I don't know the type that I'm building the expression for, I'm attempting to use reflection in the lambda functions to refer to a property, but after applying the fix suggested by @JaredPar I get the error, "The LINQ expression node type 'Invoke' is not supported in LINQ to Entities." Is there any way around this? here is my code:
Public Shared Function buildRadFilter(Of T)(ByVal filterExpression As List(Of GridFilterExpression)) As Expressions.Expression(Of Func(Of T, Boolean))
Dim returnPred = PredicateBuilder.True(Of T)()
[Code]....
View 1 Replies
Apr 2, 2010
I have a table with the below structure.
ID VALUE
1 3.2
2 NULL
4 NULL
5 NULL
7 NULL
10 1.8
11 NULL
12 3.2
15 4.7
17 NULL
22 NULL
24 NULL
25 NULL
27 NULL
28 7
I would like to get the max count of consecutive null values in the table.
View 3 Replies
Feb 15, 2010
i m trying to run a query on an MSAccess table, but it does not give me any count but only 0.
There are 3 null values which i should be getting but it does not give me the result. This query works perfectly in MSSql Server 2008.
the query is :
Quote:
SELECT COUNT(*) AS Cntr
FROM (Modul m LEFT OUTER JOIN
Relation r ON m.Mod_Name = r.von)
WHERE (m.[group] = '')
I need a workaround for this but am unable to find one.
View 2 Replies
Jun 2, 2010
I have code that's working beautifully on my development machine, but when deployed to the server is throwing null reference exception. So, I can't step through the code, but I've pinned down the culprit. But now I am puzzled.[code]In the code above persons is a dictionary of custom class, and certs is of IEnumerable type. Now here's the quandary.. The first line that sets the label returns False, so certs is not null. But the second line throws an null reference exception.
View 1 Replies
Jun 2, 2010
This is related to my previous question but it is a different problem.I have two classes: Server and Database.
[Code]...
The problem is in the LoadTables in the Server class. When it hits Databases.Add(db) it gives me a NullReference error (Object reference not set). I don't understand how it is getting that, all the objects are set.
View 4 Replies
Jun 24, 2010
I have some code which gets child items for a menu via the GetChildren function which takes a list of menuData: Dim builtMenu As New List(Of MenuData)(_rawData.FindAll(Function(item) item.GroupingID = 0))
For Each menuData As MenuData In builtMenu
If menuData.Children IsNot Nothing Then
menuData.Children.AddRange(GetChildren(menuData))
End If
Next
If I check if menudata.children isnot nothing, it always is nothing because the GetChildren function is yet to run (providing the child items, which do exist). If I remove this check and just have this code:
Dim builtMenu As New List(Of MenuData)(_rawData.FindAll(Function(item) item.GroupingID = 0))
For Each menuData As MenuData In builtMenu
menuData.Children.AddRange(GetChildren(menuData))
Next
Then I am presented with a Object reference not set to an instance of an object error on menuData.Children.AddRange(GetChildren(menuData))
View 1 Replies
Jan 8, 2011
I have been trying to use sockets in VB.NET and once I cannot understand how to avoid a null reference. [code] I have tried introducing sock as 'New Socket', but this gives me 'Overload resolution failed because no accessible New can accept this number of arguments'.I also cannot simply add '= Nothing' onto the end of my declaration since this still gives a null reference.
View 6 Replies
Jan 29, 2011
I'm practicing on this one, and I know it would be better to just use a string variable instead of a class. I have another working program using a string variable, but on this one I wanted to make it use an array of class objects.
I keep getting null reference exceptions at the line where the object is assigned the textbox text.[code...]
View 2 Replies
Dec 16, 2010
How do I check for a null object in a subroutine handle?
Private Sub Form1_KeyDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
[code]......
View 7 Replies
Mar 21, 2011
I have a null reference warning. Dummy code as follows:
Dim poo As IEnumPooTypes
Toilet.GetPooInBowl(poo)
The variable 'Poo' says it may result in an object reference not set error but I cannot use the 'New' keyword with an instance. How do I make the warning go away?
View 2 Replies
Jun 27, 2012
visual basic application prompting me a message "Object reference not set to an instance of an object". i have 2 project in one solution. One is developed in c# and other is in vb. i am calling a method of c# project in vb project. the vb code is:[code]when i debug vb project individually it works properly and when i call vb application from c# application, it prompting error. is i missed out any .net framework reference? [code]
View 1 Replies
Jan 4, 2010
Im trying to write code that will insert 'records' into an xml file, but everytime i click the button to make the changes to the XML file, it throws a null reference exception, ive gone through this code must be 100 times and cannot find what needs to be declared as 'new' as i know nodes can't be 'new' and the doc is 'new'
Imports System.Xml
Public Class frmuseradmin
[code]......
View 2 Replies
Jun 21, 2011
Im hearing about this, can someone explain it to me or please show some basic code of Lambda with explanation.
View 2 Replies
Jul 26, 2011
My site has been running fine for sometime now until recently I see in the event viewer a null reference exception in the DNN core:
DotNetNuke.Common.Globals.GetStatus() in
F:BuildsMaintenanceWorkingDirectoryLibraryCommonGlobals.vb:line
1125 at DotNetNuke.Common.Initialize.InitializeApp(HttpApplication
app) in
[code]....
the line 1125 is:
_Status = UpgradeStatus.None
Which is a property of the Globals class and an Enum Also when this happens it doesnt just do it once then sort its self it does it roughly every minute for an hour or so.I made sure all dataprovider.instances are either in a using or a try catch finally or self closing(if the reader is not used)?
View 2 Replies
Mar 7, 2011
I have the following code, which is meant to loop through a list of CheckBoxes and if checked if gets the text contained in the linked textbox through the tag of the Checkbox, i have used it before and it worked fine but this time i am getting the following error:
Null Reference Exception was unhandled
Dim DisCheckBox As CheckBox() = {chk0_6, chk6_12, chk12_18, chk18_24, chk2_3, chk3_4, chk4_5, chkXSB, chkSB, chkMB, chkLB, chkXLB, chkS, chkM, chkL, chkXL, chkXXL, chkXXXL, chkXXXXL, chkW8, chkW10, chkW12, chkW14, chkW16, chkW18, chkW20}
For Each Chk In DisCheckBox
[code]....
View 4 Replies
Jun 13, 2012
I know I'm being an idiot here and I just can't work it out. But i'm trying to take some data back from a vb.net database. It's falling over with a Object reference not set to an instance of an object error. And before the code runs it's saying the variable is being used before it's set, but I can't see how. Code:
Private taNotifications As dsDataTableAdapters.NotificationsTableAdapter = New dsDataTableAdapters.NotificationsTableAdapter
Dim notification As dsData.NotificationsDataTable = taNotifications.GetDataByClientID(userrow.UserID)
If notification.Rows.Count > 0 Then
Dim notificationrow As dsData.NotificationsRow
Dim forwardURL As String = notificationrow.ForwardLocation
End If
It falls over on the Dim forwardURL As String = notificationrow.ForwardLocation
View 2 Replies
Feb 24, 2010
P/Invoke on x64 null reference exceptions, I get null reference exceptions when I try to compile for x64 in .NET code that makes use of platform invocation services to call unmanaged code in dlls. Am I missing something obvious here?
[Code]
View 2 Replies
Jul 19, 2009
I keep getting a null reference exception w/this program, and its on the line that declares the array. I've looked it over and over and I just don't see why... Can you let me know if you see anything obvious? I'm also getting an "index out of range" exception, but it looks right to me...I declared everything with an 11 for 12 months, 0 to 11 for the intcount.
[Code]...
View 1 Replies
Nov 21, 2011
I'm having this exception while trying to get the value of a cell from a table.[code]...
View 2 Replies
Oct 23, 2009
If Not obj is Nothing and obj.IsActive Then ' null reference exception??constructions like this in C# works, because obj.IsActive is not checked if the first condition is false...
View 2 Replies
Apr 4, 2011
i have this sql transaction i am using to make sales.But when ever i run the code it give me this null reference exception.I do not really know what is wrong.
[Code]...
View 2 Replies
Sep 13, 2010
Now, when I try to debug my program, it immediately throws the exception below, this is before entering the program itself if I understand correctly. Any advice on how to resolve this? Between now and the last time I tried running debug, I had tried making a section of the program MDI, but gave up on that and delete that code. Also none of that part of the program is even in a position to be ran (the initial interface and onward do not execute that code)
[Code]...
View 7 Replies
Feb 21, 2012
I'm currently taking a VB class and i'm having trouble running my program properly.[code]
View 3 Replies
Jun 9, 2011
started learning vb.net..encountered this problem in this code: Private Sub NavigateRecords()
TextBox1.Text = ds.Tables("stdDataSet").Rows(inc).Item(0)-error msg appeared here sayin null reference evception was unhandled. Object reference not set to an instance of an object.
TextBox2.Text = ds.Tables("stdDataSet").Rows(inc).Item(1)
TextBox3.Text = ds.Tables("stdDataSet").Rows(inc).Item(2)
TextBox4.Text = ds.Tables("stdDataSet").Rows(inc).Item(3)
[Code]...
View 2 Replies
Feb 10, 2010
write know i am gettin null reference exception due to followin code
Imports System.Xml
Imports System.IO
[code].....
View 3 Replies
Jul 13, 2010
in the ReadFile() Sub, if the user tries to read a file that is not there he gets an exception
which results in the 2nd line in the Catch being executed. So far so good. But the 2nd line of
code in the mnuOpen_Click then gets a System.NullReferenceException which I don't understand since
the mnuOpen_Click code all works fine when called from the Open menu item. The exception
information suggests I use the "new" keyword to create an object instance, but in all my reading
and all the different ways I've applied the keyword New to the code, I've not been able to figure
out how to do this.[code...]
View 3 Replies