question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dictionary inside list serialization error

See original GitHub issue

I have following code structure:

image

And when serializing it this error occurs: System.ArgumentNullException: 'Value cannot be null. Parameter name: key' Stack: at System.Collections.Generic.Dictionary`2.FindEntry(TKey key) at ExtendedXmlSerializer.ExtensionModel.Xml.XmlWriter.CreatePrefix(String identifier) at ExtendedXmlSerializer.ExtensionModel.Xml.XmlWriter.Get(TypeParts parameter) at ExtendedXmlSerializer.ExtensionModel.Xml.XmlWriter.GetType(TypeInfo parameter) at ExtendedXmlSerializer.ExtensionModel.Xml.XmlWriter.Get(MemberInfo parameter) at ExtendedXmlSerializer.ExtensionModel.Xml.OptimizedNamespaceXmlWriter.Get(MemberInfo parameter) at ExtendedXmlSerializer.ContentModel.Format.FormattedContent`1.Get(IFormatWriter writer, T instance) at ExtendedXmlSerializer.ContentModel.Format.ContextualWriter`1.Write(IFormatWriter writer, T instance) at ExtendedXmlSerializer.ContentModel.DecoratedWriter`1.Write(IFormatWriter writer, T instance) at ExtendedXmlSerializer.ContentModel.Serializer`1.Write(IFormatWriter writer, T instance) at ExtendedXmlSerializer.ContentModel.Properties.Property`1.Write(IFormatWriter writer, T instance) at ExtendedXmlSerializer.ContentModel.Collections.ArrayIdentity.Write(IFormatWriter writer, Array instance) at ExtendedXmlSerializer.ContentModel.GenericWriterAdapter`1.Write(IFormatWriter writer, Object instance) at ExtendedXmlSerializer.ContentModel.Content.Enclosure`1.Write(IFormatWriter writer, T instance) at ExtendedXmlSerializer.ContentModel.SerializerAdapter`1.Write(IFormatWriter writer, T instance) at ExtendedXmlSerializer.ExtensionModel.RootInstanceExtension.Serializer.Write(IFormatWriter writer, Object instance) at ExtendedXmlSerializer.ExtensionModel.Xml.Write.Execute(Writing parameter) at ExtendedXmlSerializer.ExtensionModel.Xml.Serializer.Serialize(XmlWriter writer, Object instance) at ExtendedXmlSerializer.ExtensionModel.Xml.ExtendedXmlSerializer.Serialize(XmlWriter writer, Object instance) at ExtendedXmlSerializer.ExtensionModel.Xml.InstanceFormatter.Get(Object parameter) at ExtendedXmlSerializer.ExtensionMethodsForSerialization.Serialize(IExtendedXmlSerializer this, XmlWriterSettings settings, Object instance)

If this object is serialized by itself (and not inside the list) everything works fine.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Mike-E-angelocommented, Aug 11, 2020

Alright, good news @maxkoshevoi I managed to figure out a fix: https://github.com/ExtendedXmlSerializer/home/pull/424#issuecomment-672267042

That’s the good news. The bad news is that the fix is in the core XmlWriter component which is used by everything. All our tests pass but even at 1200+ passing tests, it makes me nervous to publish and possibly break someone else out there. Oh well, such is the life of software development/deployment. 😁

Anyways, let me know if that build treats you better. I release every Tuesday, but since this one might be impacting I will let it sit until next Tuesday and see if I can think of a better solution. Please feel free to use the preview build until then (and let me know of any further issues you encounter).

1reaction
Mike-E-angelocommented, Aug 18, 2020

This has been deployed to NuGet:

https://www.nuget.org/packages/ExtendedXmlSerializer/

Please do let me know of any problems you find and I will investigate. Thank you for improving the quality of ExtendedXmlSerializer! Closing this issue for now.

<div>ExtendedXmlSerializer 3.2.5</div><div>An extensible Xml Serializer for .NET that builds on the functionality of the classic XmlSerializer with a powerful and robust extension model.</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

When passing list of dictionary to serializer getting error ...
The many=True option is for passing a list (or queryset) of objects, not a single dictionary, hence the error message. If you're serializing...
Read more >
New Asp.NET Core 3.0 Json doesn't serialize Dictionary ...
Asp.NET Web Apis, when returning a Dictionary it fails with a NotSupportedException. I've included the exception below. Also, the ControllerBase ...
Read more >
Finally, a serializable dictionary for Unity! (extracted from ...
Hey guys, so as all you all know Unity doesn't know how to serialize generic dictionaries.
Read more >
How to write custom converters for JSON serialization - .NET
This article shows how to create custom converters for the JSON serialization classes that are provided in the System.Text.Json namespace.
Read more >
pickle — Python object serialization
Object sharing happens when there are multiple references to the same object in different places in the object hierarchy being serialized. pickle stores ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found