[FIXED] NullReference when trying to serialize an EntityCollection?

Posts   
 
    
ctadlock avatar
ctadlock
User
Posts: 60
Joined: 12-Feb-2004
# Posted on: 18-Mar-2004 01:52:32   

Im returning an object graph from a remoting server and get the following exception. I've extended the entity classes, which might be causing some of the issues. From looking at the source, this exception is because the _fields field in EntityBase2 is null. Anyone know how to fix this?

Thanks CT

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.get_IsDirty() at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2.Add(IEntity2 entityToAdd) at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2..ctor(SerializationInfo info, StreamingContext context) at CMI.v2.LLBL.HelperClasses.EntityCollection..ctor(SerializationInfo info, StreamingContext context) in c:\vss_carbon\cmi\applications\v2\llblgen\databasegeneric\helperclasses\entitycollection.cs:line 67 --- End of inner exception stack trace ---

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 18-Mar-2004 10:55:08   

Do you access IsDirty directly from the entity using an Add operation? If so, check DeserializationInProgress, a property of the EntityCollectionBase2 class. If that's true, don't call properties on the entity, like IsDirty. You can also check the IsDeserializing property of the entity itself.

The reason for this is that the Fields object of that particular entity is not yet deserialized. But because you try to access it, it throws an exception.

Frans Bouma | Lead developer LLBLGen Pro
ctadlock avatar
ctadlock
User
Posts: 60
Joined: 12-Feb-2004
# Posted on: 19-Mar-2004 00:57:33   

Im not directly accessing an entity, an exception is throw during the deserialization before I even have the ability to make call on it. The IsDirty property is being called because in EntityCollectionBase2's constructor for serialization, it calls Add() for every entity in the entity list. Take a look at the stack trace is my first message.

Thanks CT

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 19-Mar-2004 09:22:10   

Ok I see it now.

I'll fix this. It's strange, in my tests it works ok (serialization and deserialization of the object collection).

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 19-Mar-2004 20:52:01   

This issue is fixed in the update which is now available.

Frans Bouma | Lead developer LLBLGen Pro