SerializationException

Posts   
 
    
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 10-Nov-2006 10:52:41   

Hi,

SQL Server 2005 / VS 2005 / LLBLGen Pro v2.0.0.0 Demo Final / Default Template

In the database we have User table to Person table which is a 1:1. There is a Feedback table that contains a FK LoggedByUserID (from the User table) and FK RegardingPersonID (from the Person table).

We make User a Sub-Type of Person before we generate.

There is a datasourcecontrol on a webform, which a r.a.dgrid is bound too:


<llblgenpro:llblgenprodatasource id="personCollectionDataSource" runat="server" datacontainertype="EntityCollection"
    entitycollectiontypename="preLink.Data.CollectionClasses.PersonCollection, preLink.Data" enablepaging="True">
</llblgenpro:llblgenprodatasource>

When i run the page i get the following error exception:

"SerializationException: Cannot add the same member twice to a SerializationInfo object."

Source Error:

Line 402: info.AddValue("_alwaysFetchPerson", alwaysFetchPerson); Line 403: info.AddValue("_alreadyFetchedPerson", alreadyFetchedPerson); Line 404: info.AddValue("_feedback", _feedback); Line 405: info.AddValue("_alwaysFetchFeedback", _alwaysFetchFeedback); Line 406: info.AddValue("_alreadyFetchedFeedback", _alreadyFetchedFeedback);

Source File: C:\Development\Prelink\prelink\src\preLink.Data\EntityBaseClasses\PersonEntityBase.cs Line: 404

Stack Trace:

[SerializationException: Cannot add the same member twice to a SerializationInfo object.] System.Runtime.Serialization.SerializationInfo.AddValue(String name, Object value, Type type) +2704130 System.Runtime.Serialization.SerializationInfo.AddValue(String name, Object value) +57 preLink.Data.EntityClasses.PersonEntityBase.GetObjectData(SerializationInfo info, StreamingContext context) in C:\Development\Prelink\prelink\src\preLink.Data\EntityBaseClasses\PersonEntityBase.cs:404 preLink.Data.EntityClasses.UserEntityBase.GetObjectData(SerializationInfo info, StreamingContext context) in C:\Development\Prelink\prelink\src\preLink.Data\EntityBaseClasses\UserEntityBase.cs:252 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +281 System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) +50 System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) +411 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 'preLink.Data.CollectionClasses.PersonCollection' of type 'preLink.Data.CollectionClasses.PersonCollection.'] 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

Is something not being generated correctly?

Thanks

deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 10-Nov-2006 11:14:30   

Here is a picture of the database if it would help

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 10-Nov-2006 11:24:03   

Could you do a full rebuild of the solution please? Also, could you please check if you have inherited fields mapped onto relations which have the same name as the ones in the subtype entity (e.g.: Employee <- Manager and both have a relation with department. If employee has a field "Department" for the relation Employee.WorksForDepartmentID - Department.Id, and MAnager also has the field "Department", though for the relation Manager.ManagesDepartmentID - Department.Id, this will give a compilation error at runtime. To overcome this, rename one of the fields in the llblgen pro designer.

However I fail to see why this would give serialization errors if the code compiles, as the names are based on names in the entity, and therefore will also result in a compilation error.

Frans Bouma | Lead developer LLBLGen Pro
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 10-Nov-2006 12:10:45   

Tried a rebuild, it builds fine.

Still the same error when i run the page. On line:


Line 404:           info.AddValue("_feedback", _feedback);

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 10-Nov-2006 12:35:08   

could you check for me if '_feedback' is added to the info block twice in the entities involved (thus the ones in the inheritance hierarchy. PLease check the GetObjectInfo methods in the generated code). You also don't add manually to the info block?

It might be ASP.NET adds a '_feedback' member to the infoblock, I have no idea, our code doesn't do that, for sure. If you rename the Feedback field in the designer, does that make the page work at runtime? (just for testing)

Frans Bouma | Lead developer LLBLGen Pro
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 12-Nov-2006 13:09:04   

Hi,

I guess u meant GetObjectData()? It's only in there once, no i don't add manually to it.

I tried to just rename the value "_feedback" to:


info.AddValue("_feedback1", _feedback);

but then i got the same error on the next line:


info.AddValue("_alwaysFetchFeedback", _alwaysFetchFeedback);

So I renamed them all to:


info.AddValue("_feedback1", _feedback);
info.AddValue("_alwaysFetchFeedback1", _alwaysFetchFeedback);
info.AddValue("_alreadyFetchedFeedback1", _alreadyFetchedFeedback);

And the page now runs without an error. So i guess it's not an asp.net thing because it wouldn't have given an error on the line next line:


info.AddValue("_alwaysFetchFeedback", _alwaysFetchFeedback);

.

Is there anything else you can think of?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 12-Nov-2006 13:38:43   

No, I don't know of anything else. renaming them isn't useful of course, as it's overwritten in the next code generation cycle.

Could you mail us the .lgp file? support AT llblgen.com.

We'll then try to reproduce it with a similar hierarchy and page.

The point is that it's with this feedback field, as the elements added prior to this element aren't duplicates. In your model, both entities in the hierarchy have a relation with feedback.

Frans Bouma | Lead developer LLBLGen Pro
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 12-Nov-2006 13:42:51   

Ok will send it now.

Thanks very much.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 12-Nov-2006 14:04:38   

Received it, thanks. Will check it out first thing tomorrow (monday)

(edit) OK couldn't resist to have a look. Could you rename the following: Rename 'Feedback' in User to something else and try again? User has two times 'Feedback' in itself: once inherited from Person and one of itself. As User-Feedback is another relation, it's not overriding Person's Feedback field (mapped on Person - Feedback), so you've to rename either one of them in the designer.

I'd suggest to rename the field mapped onto relation User - Feedback in User to something else, re-generate code and try again. Your current code gives compile warnings with 'new' and hiding a base class member, correct? THat should go away now too.

Frans Bouma | Lead developer LLBLGen Pro