System.InvalidOperationException: An attempt was made to load a type with the fully qualified name of 'x'
See original GitHub issueHey,
I generated classes from xml schema with https://github.com/mganss/XmlSchemaClassGenerator
The XML has attribute on the root element like xmlns:tns="http://jpk.mf.gov.pl/wzor/2017/11/13/1113/"
but somehow ExtendedXmlSerializer can’t swallow it 😦. Normal XmlSerializer can but it’s kinda old and would love to switch to ExtendedXmlSerializer.
This is the schema I generated class from: https://www.gov.pl/documents/2034621/2182793/Schemat_JPK_VAT(3)_v1-1.xsd
Unhandled exception. System.InvalidOperationException: An attempt was made to load a type with the fully qualified name of 'http://jpk.mf.gov.pl/wzor/2017/11/13/1113/:JPK', but no type could be located with that name.
at ExtendedXmlSerializer.ContentModel.Extensions.GetClassification(IClassification this, IFormatReader parameter, TypeInfo defaultValue)
at ExtendedXmlSerializer.ExtensionModel.Xml.Read.Get(XmlReader parameter)
at ExtendedXmlSerializer.ExtensionModel.Xml.Serializer.Deserialize(XmlReader reader)
at ExtendedXmlSerializer.ExtensionModel.Xml.ExtendedXmlSerializer.Deserialize(XmlReader reader)
at ExtendedXmlSerializer.ExtensionMethodsForSerialization.Deserialize[T](IExtendedXmlSerializer this, XmlReaderSettings settings, Stream stream)
at ExtendedXmlSerializer.ExtensionMethodsForSerialization.Deserialize[T](IExtendedXmlSerializer this, Stream stream)
at ConsoleApp3.Program.Main(String[] args) in C:\Users\Konrad\RiderProjects\ConsoleApp3\ConsoleApp3\Program.cs:line 18
Is there anyway to make it behave more like the original XmlSerializer?
var serializer = new ConfigurationContainer().UseAutoFormatting()
.Create();
It tries to load “http://jpk.mf.gov.pl/wzor/2017/11/13/1113/:JPK” as a type but it’s not a type, it’s not even fully qualified type name so it should never try to load it.
This is how root node looks like:
<tns:JPK xsi:schemaLocation="http://jpk.mf.gov.pl/wzor/2017/11/13/1113/ https://www.gov.pl/documents/2034621/2182793/Schemat_JPK_VAT%283%29_v1-1.xsd" xmlns:tns="http://jpk.mf.gov.pl/wzor/2017/11/13/1113/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:etd="http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2016/01/25/eD/DefinicjeTypy/" xmlns:kck="http://crd.gov.pl/xml/schematy/dziedzinowe/mf/2013/05/23/eD/KodyCECHKRAJOW/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:usr="urn:the-xml-files:xslt">
thx in advance
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Could not load type from assembly error
When I execute the test through the NUnit GUI I get: WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue: System.IO.
Read more >InvalidOperationException Class (System)
An InvalidOperationException is thrown when you try to access a UI element from a thread other than the UI thread. The text of...
Read more >Language Environment runtime messages
An invalid attempt to discard the initial heap was made. ... An z/OS UNIX file system load of module module-name failed. The system...
Read more >SQL error messages and exceptions
22005, An attempt was made to get a data value of type ' <datatypeName> ' from a data value of type ... Use...
Read more >SerializeReference Attribute? | Page 4
Error : InvalidOperationException: Attempting to get the managed reference full typename on a SerializedProperty that is set to a ...
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
Should be fine to solve that serialization problem. Thanks. XML in .NET is a tough topic, probably because everyone moved on to other formats. In that particular use case it seems like using original
XmlSerializer
is unavoidable 😄 The only thing that works with “legacy” xml.Alright @bugproof after poking around at this I found another issue #200 that was similar and has a solution that involves adjustments to the extensions that are passed into the
ConfigurationContainer
constructor. Check it out:https://github.com/ExtendedXmlSerializer/home/blob/97f458c56de54f7993ba521484eda9d220be8730/test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue374Tests.cs#L18-L47
Since we are dancing around the limitations of ExtendedXmlSerializer’s legacy serialization support (trust me, it’s a sore topic 😆) my preference would be to try to stay away from touching the internals as much as possible and leverage the extension model if we can. Please let me know how that sits with you and/or any additional issues you might run into with getting this to work as desired.