CSLA 3.6: AsyncLoadManager / SerializationException

CSLA 3.6: AsyncLoadManager / SerializationException

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


PaulCoetser posted on Tuesday, September 16, 2008

Hi there,

I'am new to CSLA and I'am getting the following error:

Type 'Csla.Core.LoadManager.AsyncLoadManager' in Assembly 'Csla, Version=3.6.0.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30' is not marked as serializable.

this error get thrown from : BinaryFormatterWrapper  Serialize method.

I've got a simple screen with a grid on.  I have a simple table with 5 columns that I bind to the grid via a bindingsource.  The grid as well as my CSLA object is editable.  As soon as I change data within the grid I receive the above error.

 

code:

 

//retrieve all the account types from the database.

AccountTypes accountTypes = AccountTypes.SelectAll();

//accountTypeDS is a Bindingsource

accountTypeDS.Datasource  = accountTypes;

//assign the datasource to the grid control

gridControlResults.DataSource = accountTypeDS;

 

This is currently running as a 2-tier model.

As you can see it is very straight forward.  What am I missing?

 

Kind regards

Paul Coetser

 

RockfordLhotka replied on Tuesday, September 16, 2008

Is this the pre-release version or directly from subversion?

The current code in subversion appears to be correct - all the fields using that type are marked as NonSerialized. It is possible that an older pre-release was missing that attribute.

Or it is possible we're missing something else - but my test apps are running, including some data bound grids - so I'm hoping you are using one of the pre-releases?

detritus replied on Saturday, September 27, 2008

I also got this message yesterday but cannot reproduce it (Before the error, I updated by working copy from SVN). Saved stack trace at the time. I'm very new to CSLA so, could be something I did wrong but may be stack trace helps tracking down the reason. For me it started when RebindUI calls BeginEdit in the UI (the method is copied from Project.cs):


   at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
   at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
   at Csla.Serialization.BinaryFormatterWrapper.Serialize(Stream serializationStream, Object graph) in E:\comps\csla\trunk\cslacs\Csla\Serialization\BinaryFormatterWrapper.cs:line 40
   at Csla.Core.UndoableBase.CopyState(Int32 parentEditLevel) in E:\comps\csla\trunk\cslacs\Csla\Core\UndoableBase.cs:line 157
   at Csla.Core.BusinessBase.BeginEdit() in E:\comps\csla\trunk\cslacs\Csla\Core\BusinessBase.cs:line 947
   at PortalGrup.Rep2Doc.Win.CardEditForm.BindUI() in D:\PortalGrup\Rep2Doc\app\source\Win\MasterData\CardEditForm.cs:line 82
   at PortalGrup.Rep2Doc.Win.CardEditForm.RebindUI(Boolean saveObject, Boolean rebind) in D:\PortalGrup\Rep2Doc\app\source\Win\MasterData\CardEditForm.cs:line 108
   at PortalGrup.Rep2Doc.Win.CardEditForm.btnApply_Click(Object sender, EventArgs e) in D:\PortalGrup\Rep2Doc\app\source\Win\MasterData\CardEditForm.cs:line 68

tim.offermann replied on Tuesday, September 30, 2008

I experienced the same issue with the current 3.6.0 Beta release (080926). After an inspection of the involved code I would think that the reason for this exception can be found in the context of Csla.Core.UndoableBase : void CopyState(int parentEditLevel).

My observations so far:

The problem is, that on collecting the state the "NonSerilizable" attribute of the AsyncLoadManager in BusinessBase is ignored and the _loadManager is included int the state dictionary. Upon serialization of the (HybridDictionary!) state the exception is thrown as the AsyncLoadManager class is not marked as serilizable.

Best Regards

Tim

sergeyb replied on Tuesday, September 30, 2008

There was an issue with AsyncLoadManager field in BB not marked as NotUndoable.  The issue was corrected.

Thank you.

Copyright (c) Marimer LLC