Deserialization issue
See original GitHub issueHello there! I’m having an issue trying to make this library to work and would appreciate some help.
I have an XML like this:
<TObjItemData>
<Id>11546</Id>
<Name>SomeObjectName</Name>
...
</TObjItemData>
it is a part of a larger XML, but i need just this one Element and I send it to the Deserialize method as text. The class looks like this:
[XmlRoot("TObjItemData")]
public class DbD2Object : DataEntity
{
[XmlElement("Id")]
public long Id { get; set; }
[XmlElement("Name")]
public string Name { get; set; }
....
}
I tried all sorts of initialization of the serializer, but I think this should be the correct one (according to doc):
IExtendedXmlSerializer serializer = new ConfigurationContainer()
.ConfigureType<DbD2Object>().Name("TObjItemData")
.Create();
Then I call the Deserialize<> method like this:
DbD2Object obj = serializer.Deserialize<DbD2Object>(element.ToString());
I tried all sorts of things but no matter what I do I always get the same exception.
System.InvalidOperationException: 'An attempt was made to load a type with the fully qualified name of 'TObjItemData', but no type could be located with that name.'
I honestly don’t understand what “fully qualified name” means in this context, but I guess it has something to do with those xmlns attributes that are in every single XML in the documentation (never used them before tbh). My problem is that I cannot change the input XML in any way, as I am receiving it from an external source and I’m using the library for deserialization only.
Thanks, Esso
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (8 by maintainers)
Top GitHub Comments
Going to close this issue now. Please let me know if there are any further problems you find with it and we will reopen it. Please also feel free to open a new issue altogether if you feel that is more appropriate. 👍
Alright @esso23 you should be set to go here. I’ve updated the converter registrations to utilize a component we already had within our code, which was taken from the classic .NET Framework (
KeyedByTypeCollection
) and ensures that items that are added are keyed by their type and only get added once. This should throw any errors in case there are two objects with the same type, but it also removes items as well before adding it.Additionally, I’ve exposed all components around the
DefaultExtensions
and you should be able to extend extensions more easily now.You can find the latest version here on our preview feed: https://www.myget.org/F/wojtpl2/api/v3/index.json