1
'elementName (Parameter 'The elementObj is based on a xs:complexType, you must supply also supply the elementName.')'
Question asked by Scott Zrubek - 5/4/2020 at 9:57 PM
Answered
I'm attempting to export elements that are stored in a database into an xml file.  The barest bones of the code it:

                    SpaceSystemTypeCtDTO dto = SpaceSystemTypeCtDTO.convertModelToDTO(_context, spaceSystem);
                    LxSerializer serializer = new LxSerializer(typeof(SpaceSystemTypeCtDTO).Assembly);
                    serializer.Serialize(tteFilepath, dto, lxWriterSettings);

I'm seeing the following exception:

ArgumentNullException: elementName (Parameter 'The elementObj is based on a xs:complexType, you must supply also supply the elementName.')


I did not spot any overloads that gave me more information.  What do I need to change to get this exception cleared?

1 Reply

Reply to Thread
0
Liquid Support Replied
Employee Post Marked As Answer
Hi,

As the type you are using 'SpaceSystemTypeCtDTO' is a ComplexType, you need to also pass the elementName into the 'Serialize' method, i.e. the element of type SpaceSystemTypeCtDTO, this will be the tag name in the output XML document.


Reply to Thread