Entity XML deserialization

Posts   
 
    
miloszes1
User
Posts: 6
Joined: 03-Apr-2007
# Posted on: 29-May-2007 13:35:19   

Hi all,

I've founded some situation in which my entity object serialized to XML cannot be deserialized . It's very strange because I've serialized about 7 other object (other type objects) and everything is right for them, but still I've got one which cannot be deserialized properly.

The serialization doesn't throw any exception, but when I want to retrieve the object the following exception is throwed:

  • - e {"There is an error in XML document (1605, 21)."} System.Exception {System.InvalidOperationException}
  • - InnerException {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException}

The row and line in the exception points out the end of the XML file.

Do you have any concept, what could be wrong ?

Regards, MiloszeS

PS. Attached is the screen shot of the watch window.

Here is the code fragment in which the object is serialized and deserialized. Maybe it will be helpful.

XmlSerializer serializer = new XmlSerializer(typeof(SomeEntity));
XmlTextWriter xmlTextWriter = new XmlTextWriter(fileName, Encoding.UTF8);
XmlTextReader xmlTextReader = null;

xmlTextWriter.Formatting = Formatting.Indented;

serializer.Serialize(xmlTextWriter, someEntity);

xmlTextWriter.Close();

xmlTextReader = new XmlTextReader(fileName);

entityToRestore = serializer.Deserialize(xmlTextReader) as SomeEntity;

xmlTextReader.Close();
Attachments
Filename File size Added on Approval
DeserializationProblem.png 33,521 29-May-2007 13:35.40 Approved
fpw2377
User
Posts: 35
Joined: 23-Feb-2007
# Posted on: 29-May-2007 15:20:29   

Hi MiloszeS,

I just recently had issues with xml serialization and web services. Here is the thread:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=9935

My problem was I added a new property to my entity that was never being serialized, it was just passing a string with the full class name to the webservice so when the web service tried to recreate my object it was failing with that message.

Hope that helps,

Frank

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 29-May-2007 15:43:13   

Hello,

did you defined any custom property on your entity? If yes, it's a problem that will be corrected in the next 2.x upgrade.

miloszes1
User
Posts: 6
Joined: 03-Apr-2007
# Posted on: 29-May-2007 16:41:20   

Unfortunately, yes rage

Do you know maybe when the next 2.x will be available ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 29-May-2007 17:52:05   

miloszes1 wrote:

Unfortunately, yes rage

Do you know maybe when the next 2.x will be available ?

Hopefully a beta will be available next week.

To avoid the error now, you should add [XmlIgnore] to the property for now, which will ignore the property in the XML. Not what you'd like perhaps but then at least you can serialize the rest to XML.

Frans Bouma | Lead developer LLBLGen Pro
miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 07-Aug-2007 11:49:34   

Hello again,

yesterday We downloaded the latest LLGLGen version and the problem is still not resolved rage . Now we're serializing entity to the binary file, but it's problematic because of the server security policies.

Regards, Milosz Kubanski

PS.

[XMLIgnore] tag doesn't avoid the problem.

arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 07-Aug-2007 12:51:28   

We downloaded the latest LLGLGen version and the problem is still not resolved

Did you download the v2.5 beta or the latest v2.0 production version? From reading the thread, I would expect the resolution in the v2.5 beta.

miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 07-Aug-2007 13:05:29   

OK, now I'm get it - we've downloaded 2.0. I thought that you've got some shared repository branches for both versions (2.0 and 2.5). When - more less - can we expect 2.5 stable version ?

Regards, Milosz

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 07-Aug-2007 13:21:58   

miloszes wrote:

OK, now I'm get it - we've downloaded 2.0. I thought that you've got some shared repository branches for both versions (2.0 and 2.5). When - more less - can we expect 2.5 stable version ?

Regards, Milosz

It's pretty stable in current beta form, there are no known bugs at the moment. We're working hard to get the docs finished and then we'll have a release, so that will hopefully be next week.

Frans Bouma | Lead developer LLBLGen Pro
miloszes
User
Posts: 222
Joined: 03-Apr-2007
# Posted on: 07-Aug-2007 13:38:54   

OK. Thank you for an answer and help.

Milosz

arschr
User
Posts: 893
Joined: 14-Dec-2003
# Posted on: 07-Aug-2007 15:43:27   

I thought that you've got some shared repository branches for both versions (2.0 and 2.5)

I think this is a breaking change to the v2.0 branch.