Serializable question

Posts   
 
    
Posts: 5
Joined: 24-Sep-2007
# Posted on: 24-Sep-2007 15:50:04   

We are running some performance tuning tests on an Time Tracking application. We are running LLBLGen 2.0 (SelfServicing, Two Classes), 2.0 Framework, and C#.

One of the performance tuning tests was to try using typedLists in replace of Prefetch Paths. This produced a tremendous savings in retreival time. We utilize a ServiceFacade, which holds custom classes and properties and serves as a "mapping" layer between the DAL that LLBLGen generates and the UI. The ServiceFacade holds all the getting, updating, inserting, and deleting classes and provides a "friendly" class for the UI developers to interface with. The UI programmers interacts with the ServiceFacade, not the DAL, to create their pages.

Any who...when modifying one of our methods in the ServiceFacade to utilize the new TypedList, it works at times, and at other times it blows up. I am having trouble tracking down the issue at hand. As I step through the code, I get no specific error message that could point me in the right direction. I get the following error consistently on several pages. But it works on others...so is the mix of using Entities/PrefetchPaths and the TypedList causing me issues? Anyway, any information you can provide would be greatly appreciated. Error is below...

Server Error in '/' Application.

Type 'TMSDAL.TypedListClasses.GetAllTmsUsersRow' in Assembly 'TMSDAL, Version=1.0.2820.27157, Culture=neutral, PublicKeyToken=null' is not marked as serializable. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.Serialization.SerializationException: Type 'TMSDAL.TypedListClasses.GetAllTmsUsersRow' in Assembly 'TMSDAL, Version=1.0.2820.27157, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SerializationException: Type 'TMSDAL.TypedListClasses.GetAllTmsUsersRow' in Assembly 'TMSDAL, Version=1.0.2820.27157, Culture=neutral, PublicKeyToken=null' is not marked as serializable.] System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +2271925 System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +245 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +88 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) +161 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) +46 System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +504 System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +489 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +131 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) +12 System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +2849

[ArgumentException: Error serializing value 'System.Collections.Generic.List1[TmsServiceFacade.MyProjects]' of type 'System.Collections.Generic.List1[[TmsServiceFacade.MyProjects, TmsServiceFacade, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].'] System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer, Object value) +3056 System.Web.UI.ObjectStateFormatter.Serialize(Stream outputStream, Object stateGraph) +126 System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph) +52 System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Serialize(Object state) +4 System.Web.UI.Util.SerializeWithAssert(IStateFormatter formatter, Object stateGraph) +37 System.Web.UI.HiddenFieldPageStatePersister.Save() +106 System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state) +82 System.Web.UI.Page.SaveAllState() +552 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1676


Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 24-Sep-2007 18:57:01   

Hi, could you please paste the code that produces the exception?

Posts: 5
Joined: 24-Sep-2007
# Posted on: 24-Sep-2007 19:22:14   

It is happens between creating the list of MyProject class, and creating a list of TMSTime class. I get past the MyProject class, but the second it hits the TMSTime class class, kablooeey...I cannot even begin to step into it...

namespace TmsPortal.TimeSheet { public partial class DayView : TmsBasePage { int rowcount = 0; int leaveRowcount = 0; string btnComments = "btnComm"; string strProjects = "radCboProject"; string strhideComm = "hideComm"; string strhideTimeId = "hideTime"; string strTime = "txtTime"; string strDelete = "btnDelete"; string strTasks = "radCboTask"; string strImgBtn = "imgBtnEdit"; string strHF = "lblHF";

    string lastProjectAndTask = "";
    char firstTime = 'y';
    int payPeriodStatus = 0;

    **List<MyProjects> lstProj = new List<MyProjects>();

    List<TMSTime> _lstTime = new List<TMSTime>();**

    protected void Page_Load(object sender, EventArgs e)
    {

.... }}

Posts: 5
Joined: 24-Sep-2007
# Posted on: 24-Sep-2007 21:27:14   

I could not get rid of the error until I deleted the typedList, regenerated the DAL, and deleted the typedlist.cs file from source control. I also had to comment out all code that referenced the typedListRow (due to deleting of the files), and everything runs fine. Are there issues with using PrefetchPaths/Collections/Entities AND TypedLists together in the same class because one is serializable and one not? As I dug deeper, the error was from an EntityBase class at the base.GetObjectData(...).

/// <summary> ISerializable member. Does custom serialization so event handlers do not get serialized. /// Serializes members of this entity class and uses the base class' implementation to serialize the rest.</summary> /// <param name="info"></param> /// <param name="context"></param> [EditorBrowsable(EditorBrowsableState.Never)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("_dcarLeave", _dcarLeave); info.AddValue("_alwaysFetchDcarLeave", _alwaysFetchDcarLeave);

. . . // __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo // __LLBLGENPRO_USER_CODE_REGION_END base.GetObjectData(info, context);

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-Sep-2007 11:47:32   

Are there issues with using PrefetchPaths/Collections/Entities AND TypedLists together in the same class because one is serializable and one not?

No, at least not that I know of.

As I dug deeper, the error was from an EntityBase class at the base.GetObjectData(...).

Have you extended the envolved entity and added any custom properties/fields?

Posts: 5
Joined: 24-Sep-2007
# Posted on: 25-Sep-2007 14:35:01   

No custom properties or fields. We would really like to switch all the collection.GetMulti and prefetchPaths to typedlists for query purposes as they prove to be much faster. If we cannot solve this, I do not have any other options. I'm running version: 2.0.0.0 Final (August 3rd, 2006). Would a newer version correct the problem?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Sep-2007 12:00:57   

If you reference the typedlist row (which is causing the problem) from the entity class. This might be the cause: the typedlist is serialized as a whole as it's a datatable, rows aren't serializable individually. The serialization is performed by the viewstate code of asp.net

Posts: 5
Joined: 24-Sep-2007
# Posted on: 26-Sep-2007 15:52:00   

Is there a way to fix this? Can LLBLGen serialize the rows? Why or why not? Are you telling me I'm out of luck? What other methods can I use to speed up the retrieval process other than Prefetch Paths? We are using SelfServicing TwoClasses... Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Sep-2007 16:44:25   

A TypedList is infact a DataTable, can you serialize a a row in a DataTable. The only way I can see is to attach a single DataRow to a DataTable and serialize the DataTable. So if you don't want to serialize the entire TypedList, copy that row to another empty TypedList or dataTable and serialize it.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 28-Sep-2007 10:24:45   

To elaborate a bit: a datarow has no meaning: the meaning of the fields inside a datarow is stored in the datatable. This means that a row in a typedlist has no real meaning without the column info of the typedlist class (the datatable).

Frans Bouma | Lead developer LLBLGen Pro