BindingList Serialization Bug Revisited in CSLA 3.5/3.6

BindingList Serialization Bug Revisited in CSLA 3.5/3.6

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


Spencer posted on Wednesday, November 12, 2008

I am experiencing a problem with the BusinessListBase class, regarding serialization. The exception seems vaguely familiar to the exception that happened with earlier versions and was subsequently fixed. Here is the message:

Type 'System.ComponentModel.ReflectPropertyDescriptor' in Assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.


Has anyone else seen this exception with the BusinessListBase class? It is happening on DataPortal_Update().

Thank you for any help you can provide.

ajj3085 replied on Thursday, November 13, 2008

I would suspect that your subclass isn't marked as Serializable, or you have something in your BO that isn't marked as serializable.

Spencer replied on Thursday, November 13, 2008

You would think that was the case, but these objects work perfectly with CSLA 3.0.5. It's almost like the bug related to attempted serialization of declared events is back...

I never had to deal with it in 2.0, because it was fixed for the version of CSLA we were using for .net 2.0 before we started using CSLA. I do not want to create my own BusinessListBase to fix this though... 

 
 

ajj3085 replied on Thursday, November 13, 2008

Do you have any other information?  I don't recall this bug in 2.x, and I'm using 3.6 beta 2 refresh without issue.

RockfordLhotka replied on Thursday, November 13, 2008

I don't think it is a BLB issue, at least in general. I say this because lots of people use 3.5, and a number of people use 3.6, and their classes work :)

Which is not to say there might not be some specific BLB feature that you are triggering that has a bug.

Nor is it to say that your code might not have some issue - though I appreciate that it worked in 3.0.x.

So here's my current question: does it work in CSLA 3.0.x running on .NET 3.5? Since there are new compilers and framework changes in .NET 3.5, I know that there've been some small and subtle things that people have encountered just by switching runtimes - especially around reflection and code access security.

It seems pretty clear from your exception that something (your code, BLB, etc) is somehow holding a reference to a PropertyDescriptor object. BLB does interact with some PropertyDescriptor objects, so it is possible that there's an obscure bug where it somehow holds an instance reference to one of them.

So here's another question: You can repeat this issue in both 3.5.2 and 3.6?

 

Spencer replied on Thursday, November 13, 2008

Thank you very much for your help. This issue has been resolved. You were correct, it was a reference being held to a PropertyDescriptor object.

I had to mark _SortPropertyCore as NonSerializable; a private field that I was using for the BindingList<T>.SortPropertyCore property. I honestly did not anticipate having to change anything related to the sorting method overrides I created to implement sorting in my list objects, so I did not even review that region for a PropertyDescriptor object.

Copyright (c) Marimer LLC