“Object of type ‘System.collection.generic.list`1[Lms.WebApp.BO.Account]’ cannot be converted to type ‘Csla.Core.MobilList`1 [Lms.WebApp.BO.Account]’ ”.

“Object of type ‘System.collection.generic.list`1[Lms.WebApp.BO.Account]’ cannot be converted to type ‘Csla.Core.MobilList`1 [Lms.WebApp.BO.Account]’ ”.

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


Riz posted on Thursday, January 30, 2014

Hi Everyone

Currently we are using CSLA version 2.1.4 along with .NET version 3.5. Now we are looking for CSLA version upgrade. After doing some investigation we decided to upgrade the CSLA version to “3.8.3”. So to start with we first upgraded the CSLA version to 3.8.3 then also changed the .NET framework version to 4.5 for web application, and for the libraries and BO’s we keep the .NET Framework version as 3.5. After doing these changes we build all our projects the build was successful with upgraded CSLA version 3.8.3. Now while testing the webpages we come across one issue as mentioned below:

Error:

 “Object of type ‘System.collection.generic.list`1[Lms.WebApp.BO.Account]’ cannot be converted to type ‘Csla.Core.MobilList`1 [Lms.WebApp.BO.Account]’ ”.

While debugging the code we are  getting the issue, when deserializing the “object”.

How can we fix the above mentioned issue, we are not able to get any proper solution to fix this issue.  

 

Thanks for your help in advance.

JonnyBee replied on Thursday, January 30, 2014

You cannot use the standard List<T> object with the MobileFormatter (serialize/deserializer) . You must use one of the list objects provided by CSLA such as 

Riz replied on Friday, January 31, 2014

Thanks for your reply Jonny.

Actually we don’t want to use the “MobileFormatter” as there are many classes in which we will need to do the changes which will be not feasible for us now so by considering this is there any way to use the “BinaryFormatter” as it was used in earlier csla versions and then can we generate the “StandardList” instead of "MobileList" while using the CSLA version 3.8.3. If this is possible then where shall we do these changes?

 

We appreciate your help on  this.

JonnyBee replied on Saturday, February 01, 2014

Hi,

  1. You should verify that all layers of your application use the same CSLA dll (and version) as well as configuration. 
  2. If your cient side DataPortal is configured to use MobileFormatter the I would expect to get that exception. 
  3. Make sure that none of your code actually uses List<T> directly - I would recommend to use the builtin list types in CSLA for business objects.

 

Riz replied on Monday, February 03, 2014

Hi Jonny.

We have some more questions for you and need your suggestion on them as well, as told earlier we are currently using CSLA version 2.1.4. So what path shall we follow while we upgrade to higher CSLA versions?

Shall we first upgrade the csla version to 3.5.3, as after going through some of the CSLA forum links we found that upgrading the CSLA version from 2.1.4 to 3.5.3 is not that much tough than directly upgrading to higher versions than 3.5.3. What is your though t on this?

 Is it really simpler to upgrade till version 3.5.3 than directly upgrading to versions 3.8.3 OR 4.0 and above csla versions?

 

As in our case there are lots of BO classes where we need to modify the code if there are any major changes while upgrading the CSLA version. Please advice, so that we can follow the proper steps for upgrading the csla version.

JonnyBee replied on Monday, February 03, 2014

Well, it's been awhile since I worked on version 2 and 3. 

You definitely have a lot of work to move to CSLA 4.x as all properties must be changed to have PropertyInfo and you _should_ also rewrite all your custom business rules to be classes for the v4 RuleEngine. 

So assuming you do not want to do all that you can only move up to CSLA 3.5 or newer with relatively small efforts. 

As I said - it has been a while since I worked on those version - but I would try to go to CSLA 3.8.3 and get all the bugfixes and improvements done so far. 

You should also read the change log for each version as this provides details on breaking changes that you may hit. 

 

 

Copyright (c) Marimer LLC