NullReferenceException of ExtendedXmlSerializer.Deserialize()
See original GitHub issueI’m trying to Deserialize the following XML which was produced by ExtendedXmlSerializer:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfIPreflightCheck>
<DiskSpace type="ImageMenu.PreflightChecks.DiskSpace">
<MinimumMb>20480</MinimumMb>
<RecommendedMb>40960</RecommendedMb>
<DiskNumber>0</DiskNumber>
<Name>Disk 0 Size Check</Name>
</DiskSpace>
</ArrayOfIPreflightCheck>
Yet I immediately get a NullReferenceException.
Here’s my code:
public class DiskSpace : IPreflightCheck
{
public uint MinimumMb { get; set; }
public uint RecommendedMb { get; set; }
public ushort DiskNumber { get; set; }
public DiskSpace(ushort diskNumber, uint minimumMb, uint recommendedMb)
{
DiskNumber = diskNumber;
MinimumMb = minimumMb;
RecommendedMb = recommendedMb;
Name = $"Disk {DiskNumber} Size Check";
}
public string Name { get; set; }
[XmlIgnore]
public PreflightCheckStatus Status { get; private set; }
[XmlIgnore]
public string Message { get; private set; } = "";
public PreflightCheckStatus Validate()
{
...
}
}
public interface IPreflightCheck
{
string Name { get; }
PreflightCheckStatus Status { get; }
string Message { get; }
PreflightCheckStatus Validate();
}
var diskSpace = new DiskSpace(0, 20 * 1024, 40 * 1024);
var t = new ExtendedXmlSerializer();
var xml = t.Serialize(diskSpace);
var co = t.Deserialize<DiskSpace>(xml);
Any ideas what the problem might be? I’m using version 1.5
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
NullReferenceException in ExtendedXmlSerializer #23
Hey, I get a NullReferenceException with this code: var xml = ResourceManager.GetString($"Scenes/{ name }.xml"); var serializer = new ...
Read more >Deserialization NullReferenceException Object Reference ...
It NEEDS that FindTypeB(id) function to be called, TypeB is made up elsewhere in the program at a very specific moment (which happens...
Read more >Welcome! — ExtendedXmlSerializer 4.0 documentation
Serialization class with property interface; Serialization circular reference and reference Id; Deserialization of old version of xml; Property encryption ...
Read more >Extended XML Serializer for .NET
Deserialization xml from standard XMLSerializer; Serialization class, struct, ... SubjectByFactory() : this(null) {} // Used by serializer.
Read more >XML deserialize creating null object
hello first time using XML, so ifigured i run into some issues I been able to figure out some of them, but I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Of course if this issue will take many time in first step we can add only message “Type X doesn’t have public constructor without parameters” or something like that.
I will be closing this issue since it is captured by #8 and opening another issue for the cool Protobuf constructor serialization. Please let me know if I have something misunderstood and/or feel free to re-open this issue as well.