JsonDataSource throws System.Data.DuplicateNameException using .NET

Hi

I have found another version of this bug (DuplicateNameException on Json serialize ) and have narrowed it down to a more generic setup.

The issue is present when there is a base class shared by many instances that can be null.
In this case Employee and Reviewer are always contained within DocReviews but can be null if they are not filled in.

I have attached another solution that has a more generic solution.

BrokenJsonLoading.zip (1.6 KB)

@nross

Could you please attach your input Word document here for testing? We will investigate the issue on our side and provide you more information.

@tahir.manzoor it fails before that point. There is no need to for a document, the issue is in the json data source.

@nross

We have tested the scenario using the latest version of Aspose.Words for .NET 20.11 and have not found the shred issue. So, please use Aspose.Words for .NET 20.11.

Hi @tahir.manzoor

I am still having the error on my side.

Nuget package installed
image.png (24.2 KB)

The error I am getting:
image.png (45.1 KB)

It is running in Core 3.1
image.png (9.3 KB)

Please advise if you cannot replicate it as I am still having the issue

Also I removed the line for the document as it is not needed.
The code is simply:

            var jop = new JsonDataLoadOptions();
			jop.SimpleValueParseMode = JsonSimpleValueParseMode.Loose;

			var json = new JsonDataSource("BuggyLoadJson.Json", jop);

			//ensure compiler does not optimize away json var 
			Console.Write(json);

The stack trace from the error is the following:

Unhandled Exception: System.Data.DuplicateNameException: Cannot add a column named ‘Reviewer’: a nested table with the same name already belongs to this DataTable.
at System.Data.DataColumnCollection.RegisterColumnName(String name, DataColumn column)
at System.Data.DataColumnCollection.BaseAdd(DataColumn column)
at System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column)
at System.Data.XSDSchema.HandleElementColumn(XmlSchemaElement elem, DataTable table, Boolean isBase)
at System.Data.XSDSchema.HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, Boolean isBase)
at System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, Boolean isNillable)
at System.Data.XSDSchema.InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, Boolean isRef)
at System.Data.XSDSchema.HandleTable(XmlSchemaElement node)
at System.Data.XSDSchema.HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, Boolean isBase)
at System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, Boolean isNillable)
at System.Data.XSDSchema.InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, Boolean isRef)
at System.Data.XSDSchema.HandleTable(XmlSchemaElement node)
at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)
at System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
at System.Data.DataSet.InferSchema(XmlDocument xdoc, String[] excludedNamespaces, XmlReadMode mode)
at System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving)
at System.Data.DataSet.ReadXml(Stream stream)
at ? . (XmlDocument )
at ? .(String , Stream ,? )
at Aspose.Words.Reporting.JsonDataSource…ctor(String jsonPath, JsonDataLoadOptions options)
at BrokenJsonLoading.Program.Main(String[] args) in BugTrackingWithAspose\BrokenJsonLoading\Program.cs:line 18

@nross

Thanks for sharing the detail. We have logged this problem in our issue tracking system as WORDSNET-21430. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor
I see the issue was closed again, is this not a bug?

@nross

This issue has been resolved and its fix will be available in the next version of Aspose.Words i.e. 20.12. We will inform you via this forum thread once this release is available.

@tahir.manzoor Ok thank you

The issues you have found earlier have been fixed in this Aspose.Words for .NET 20.12 update and this Aspose.Words for Java 20.12 update.