Problem with Enum property on custom entity

Posts   
 
    
CowHills
User
Posts: 47
Joined: 14-Mar-2007
# Posted on: 29-Aug-2011 11:41:33   

Hey There,

We are unable to deserialize an Entity which has an Enum property on it.

The error:There is an error in XML document (73, 13). Inner Exception: "Object reference not set to an instance of an object." at "SD.LLBLGen.Pro.ORMSupportClasses.XmlHelper.XmlValueToObject(String typeName, String xmlValue]"

We've created an sample solution to reproduce the problem.


using System;
using System.Xml.Serialization;
using System.IO;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace RepEntSer
{
    [Serializable]
    public enum TestEnum
    {
        First,
        Second
    }

    public class GeneratedEntityBase2 : EntityBase2
    {
        // Generated code here
    }

    [XmlInclude(typeof(TestEnum))]
    public class TestClass : GeneratedEntityBase2
    {
        public TestEnum Status
        {
            get { return m_Status; }
            set { m_Status = value; }
        }

        private TestEnum m_Status = TestEnum.First;
    }

    class Program
    {
        static void Main(string[] args)
        {
            TestClass testClass = new TestClass();

            StringWriter writer = new StringWriter();
            XmlSerializer serializer = new XmlSerializer(typeof (TestClass));
            serializer.Serialize(writer, testClass);
            
            string serializedXml = writer.ToString();

            StringReader reader = new StringReader(serializedXml);
            TestClass deserializedTestClass = (TestClass) serializer.Deserialize(reader);
        }
    }
}

Could anybody explain to me what is going wrong? Is this an LLBLgen issue or is it an wrong implementation?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Aug-2011 12:00:26   

Which runtime library version are you using?

CowHills
User
Posts: 47
Joined: 14-Mar-2007
# Posted on: 29-Aug-2011 12:00:57   

Walaa wrote:

Which runtime library version are you using?

Version 2.0

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Aug-2011 12:47:55   

That's not the runtime library version (build) number. Please check the following link: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7717

CowHills
User
Posts: 47
Joined: 14-Mar-2007
# Posted on: 29-Aug-2011 12:57:28   

Hey Walaa,

That will be 2.0.07.0705, using Adapter templates

SQL server 2005 and 2008

.NET versie 3.5.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Aug-2011 16:40:28   

Could you please pul the latest release of v.2.0 (Id also encourage you to move to the free v.2.6)

Please check these threads: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=12560 http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=11916 http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7961

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 29-Aug-2011 18:08:36   

V2.0 didn't have an enum serialization fix after that build date. v2.5 did though. I emailed Andre about this.

It's recommended to upgrade to v2.6 indeed, which has all v2.5 fixes as well. To rule out that a fix posted after the build date you're using fixes this, it's indeed recommended to at least try the latest v2.0 build.

Frans Bouma | Lead developer LLBLGen Pro
CowHills
User
Posts: 47
Joined: 14-Mar-2007
# Posted on: 31-Aug-2011 09:06:03   

I've downloaded 2.6 and did a test with our example. Everything is working fine. Problem solved. Now we only have migrate our application to 2.6. smile . That's going to be challenge.sunglasses