Object reference not set to an instance of an object” at Csla.LinqBindingList`1.d__0.MoveNext() in D:\Softwares\cslacs-3.5.3-090205\cslacs\Csla\Linq\LinqBindingList.cs:line 775

Object reference not set to an instance of an object” at Csla.LinqBindingList`1.d__0.MoveNext() in D:\Softwares\cslacs-3.5.3-090205\cslacs\Csla\Linq\LinqBindingList.cs:line 775

Old forum URL: forums.lhotka.net/forums/t/12345.aspx


Riz posted on Thursday, February 06, 2014

Hello Everyone.

We have upgraded our clsa version from “2.1.4” to “3.5.3”, and after the up-gradation we have successfully build all of our projects and the solution as well. While doing the unit testing after the csla upgrade we come across one scenario where we are getting an issue as shown below:

“Object reference not set to an instance of an object”
at Csla.LinqBindingList`1.d__0.MoveNext() in D:\Softwares\cslacs-3.5.3-090205\cslacs\Csla\Linq\LinqBindingList.cs:line 775

When we debug the code we got the issue at highlighted point:

if (Family.Addresses.Count > 0)

 {
     var familyAddress = Family.Addresses;
     ListViewCommonAddresses.DataSource = familyAddress;
     ListViewCommonAddresses.DataBind();

}

As we are facing the same kind of issue at other pages also where similar kind of code has been used, so we googled a bit and found out that to fix this kind of issue we can use the following solution as highlighted below:

if (Family.Addresses.Count > 0)

 {

     var familyAddress = Family.Addresses.ToList();
     ListViewCommonAddresses.DataSource = familyAddress;
     ListViewCommonAddresses.DataBind();

   }

By doing this change in that particular piece of code that issue was resolved but as told earlier we have some existing code where same kind of code has been implemented at multiple places already.

Also while finding the fix for this issue we come across some links in the csla forum where it has been mentioned that the same kind of issue has been fixed in some higher csla versions such as “3.6.1” and above, but in our case we currently cannot directly move to those higher versions as there will be a lot of code changes in the BO classes of our project, which are not feasible for us now.

Question: So is there any common solution to fix this kind of issue by doing some modification at one place by which we are able to solve this issue without the code modifications at other files as well? As told earlier we are facing this issue after we have upgraded the csla version from “2.1.4” to “3.5.3”.

Please advice. 

JonnyBee replied on Friday, February 07, 2014

One option you have is to download the code for CSLA 3.5.3 and update the LinqBindingList call to the latest version to get all bugfixes and then compile your own version of CSLA 3.5.3.

I know there is some bugfixes for SortedBindingList and FileteredBindingList as well that you may or may not use in your application.

Copyright (c) Marimer LLC