Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Serialization problem after migrating from 2.0.792 to 2.0.805 and 2.0.810 #390

Open
anoordover opened this issue Jul 1, 2023 · 3 comments

Comments

@anoordover
Copy link

anoordover commented Jul 1, 2023

After migrating my code-generation from 2.0.792 to 2.0.805 and 2.0.810 I get the following stack-trace when serializing my objects. Of course I want to help to solve this issue but I don't know where to start. I can't change the xsd's I use for code-generation (provided by an external party).

System.InvalidOperationException: There was an error reflecting type 'Xyz.Btl.Common.EuropeesBericht.Versie42.Eessi.Eessi_MessageType'.

System.InvalidOperationException
There was an error reflecting type 'Xyz.Btl.Common.EuropeesBericht.Versie42.Eessi.Eessi_MessageType'.
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportElement(TypeModel model, XmlRootAttribute root, String defaultNamespace, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defaultNamespace)
   at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
   at Xyz.Btl.Common.XmlHelpers.XmlHelpers.XmlStreamingHelper.ParseToXElement[T](T objectToBeParsed)
   at Xyz.Btl.Common.XmlHelpers.XmlHelpers.XmlStreamingHelper.GetName[T](T rootObject, Func`2 getElementFunc)
   at Xyz.Vbo.Application.Fases.SedCreators.versie42.SedCreator.CreateForSbd() in /home/arno/RiderProjects/VBO_NET/source/VboServices/Application/Xyz.Vbo.Application.Fases/SedCreators/versie42/SedCreator.cs:line 182
   at Xyz.Vbo.Application.Fases.SedCreators.versie42.SedCreator.CreateForHolodeck() in /home/arno/RiderProjects/VBO_NET/source/VboServices/Application/Xyz.Vbo.Application.Fases/SedCreators/versie42/SedCreator.cs:line 199
   at Xyz.Vbo.Application.Fases.SedCreators.versie42.SedCreatorHelper.CreateXStreamingElement(ICreator creator, SedMetadata sedMetadata) in /home/arno/RiderProjects/VBO_NET/source/VboServices/Application/Xyz.Vbo.Application.Fases/SedCreators/versie42/SedCreatorHelper.cs:line 11
   at Xyz.Vbo.Application.Wuvo.Fases.AntwoordBetwistingen.Vertalen.Awod.Da017Creator.<>c__DisplayClass5_0.<<Create>b__0>d.MoveNext() in /home/arno/RiderProjects/VBO_NET/source/VboServices/Application/WUVO/Xyz.Vbo.Application.Wuvo.Fases/AntwoordBetwistingen/Vertalen/Awod/Da017Creator.cs:line 44
--- End of stack trace from previous location ---
   at Xyz.Vbo.Application.FasesTest.AntwoordBetwistingen.Vertalen.Awod.Da017CreatorTests.Da017CreatorTest(String codeAntwoordBetwisting) in /home/arno/RiderProjects/VBO_NET/source/VboServices/Tests/Application/Fases/Xyz.Vbo.Application.FasesTest/AntwoordBetwistingen/Vertalen/Awod/Da017CreatorTests.cs:line 109
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_0.<<InvokeTestMethodAsync>b__1>d.MoveNext() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestInvoker.cs:line 264
--- End of stack trace from previous location ---
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in /_/src/xunit.execution/Sdk/Frameworks/ExecutionTimer.cs:line 48
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in /_/src/xunit.core/Sdk/ExceptionAggregator.cs:line 90

System.InvalidOperationException
There was an error reflecting property 'StandardBusinessDocument'.
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting type 'Xyz.Btl.Common.EuropeesBericht.Versie42.sbdh.StandardBusinessDocument'.
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting property 'S080'.
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting type 'Xyz.Btl.Common.EuropeesBericht.Versie42.s080.S080'.
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting property 'Signature'.
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting type 'Xyz.Btl.Common.EuropeesBericht.XmlDigitalSignature.SignatureType'.
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting property 'KeyInfo'.
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting type 'Xyz.Btl.Common.EuropeesBericht.XmlDigitalSignature.KeyInfoType'.
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting property 'PGPData'.
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting type 'Xyz.Btl.Common.EuropeesBericht.XmlDigitalSignature.PGPDataType'.
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)

System.InvalidOperationException
There was an error reflecting property 'PGPKeyPacket1'.
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)

System.InvalidOperationException
The XML element 'PGPKeyPacket' from namespace 'http://www.w3.org/2000/09/xmldsig#' is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.
   at System.Xml.Serialization.XmlReflectionImporter.AddUniqueAccessor(INameScope scope, Accessor accessor)
   at System.Xml.Serialization.XmlReflectionImporter.AddUniqueAccessor(MemberMapping member, INameScope elements, INameScope attributes, Boolean isSequence)
   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)

@anoordover
Copy link
Author

Might this be a problem:

<complexType name="PGPDataType"> 
  <choice>
    <sequence>
      <element name="PGPKeyID" type="base64Binary"/> 
      <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/> 
      <any namespace="##other" processContents="lax" minOccurs="0"
       maxOccurs="unbounded"/>
    </sequence>
    <sequence>
      <element name="PGPKeyPacket" type="base64Binary"/> 
      <any namespace="##other" processContents="lax" minOccurs="0"
       maxOccurs="unbounded"/>
    </sequence>
  </choice>
</complexType>

@anoordover
Copy link
Author

Duplicate with #378?

@mganss
Copy link
Owner

mganss commented Jul 3, 2023

Yes, this is the same issue as #378. Although you might not be able to change the upstream XSD, perhaps you can create an XSD as described in #378 (comment) just for the purpose of creating C# code. The resulting code will be able to deserialize XML documents that comply with the original XSD. If you want to serialize also, you just have to make sure that either one of PGPKeyId or PGPKeyPacket is non-null to comply with the original schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants