StackOverflowException when using generated code

Aug 15, 2012 at 10:03 AM
Edited Aug 15, 2012 at 10:04 AM

I generated code from a xsd of a UBL variant, using xsd2code v3.4.
When using the code, for example to serialize or deserialize, it throws an exception, StackOverflowException, because in a constructor (PartyType), the object is being created recursively. Every PartyType object seems to have an agent of the PartyType object.

I tried PropertyParams > EnableLazyLoading = true, but that doesn't help; StackoverflowExceptions are still thrown, but at other locations.

The xsd is located at http://www.nltaxonomie.nl/UBL/2.0/xsd/maindoc/UBL-NL-Invoice-1.0.xsd

My settings are <NameSpace>Pocus.BLL</NameSpace><Collection>List</Collection><codeType>CSharp</codeType><EnableDataBinding>False</EnableDataBinding><EnableLazyLoading>False</EnableLazyLoading><TrackingChangesEnable>False</TrackingChangesEnable><GenTrackingClasses>False</GenTrackingClasses><HidePrivateFieldInIDE>False</HidePrivateFieldInIDE><EnableSummaryComment>False</EnableSummaryComment><VirtualProp>False</VirtualProp><IncludeSerializeMethod>True</IncludeSerializeMethod><UseBaseClass>False</UseBaseClass><GenBaseClass>False</GenBaseClass><GenerateCloneMethod>False</GenerateCloneMethod><GenerateDataContracts>False</GenerateDataContracts><CodeBaseTag>Net35</CodeBaseTag><SerializeMethodName>Serialize</SerializeMethodName><DeserializeMethodName>DeserializeDoNotUse</DeserializeMethodName><SaveToFileMethodName>SaveToFile</SaveToFileMethodName><LoadFromFileMethodName>LoadFromFile</LoadFromFileMethodName><GenerateXMLAttributes>True</GenerateXMLAttributes><EnableEncoding>True</EnableEncoding><AutomaticProperties>False</AutomaticProperties><GenerateShouldSerialize>False</GenerateShouldSerialize><DisableDebug>False</DisableDebug><PropNameSpecified>Default</PropNameSpecified><Encoder>UTF8</Encoder><CustomUsings></CustomUsings><ExcludeIncludedTypes>False</ExcludeIncludedTypes><EnableInitializeFields>True</EnableInitializeFields>

Has anyone an idea what I'm doing wrong, or what setting I should adjust?

Sep 18, 2012 at 1:57 AM

This is the only way that I have been able to get around this problem.

http://xsd2code.codeplex.com/workitem/7419