1,459 questions
0
votes
3
answers
82
views
Deserialization backward compatibility when type of property has changed
I used to have simple classes like below:
public class Product {
public Money Price {get; set;}
}
public class Money {
public decimal Amount {get; set;}
public CurrencyEnum Currency {get;set;...
-3
votes
2
answers
110
views
XmlSerializer: how to ignore derived class
I have two classes
public class Base
{
public int val { get; set; } = 10;
}
public class Derived : Base
{
public int val2 { get; set; } = 20;
}
Then in the main code I have:
XmlSerializer ...
0
votes
0
answers
74
views
Supporting asynchronous streaming using XMLSerializers in .NET Core
I want to use XML serializers as output formatters for ASP.NET Core web controller returning an IAsyncEnumerable<Movie>.
The async streaming works fine when using System.Text.Json (.NET 9.0). If ...
1
vote
1
answer
215
views
Microsoft.XmlSerializer.Generator nuget package and .NET Framework
I have a .net framework project that needs to be build The Project.XmlSerializers.dll. It was using the old style csproj file format and I converted to the new SDK style project. I then added the ...
0
votes
0
answers
36
views
How to add a namespace in front of an XML root? [duplicate]
I am using the following code to add namespace to my XmlSerializer to add the following namespaces.
The class:
[XmlRoot(ElementName = "TS332")]
public class TS332Model
{
}
Adding the ...
1
vote
1
answer
57
views
Why XmlSerializer.UnknownAttribute/UnknownNode event raised when deserializing child classes?
I have been having problem with deseriailizing XML code genereated by XmlSerializer when child classes are used. The UnknownAttribute and UnknownNode events triggers and I assumed there was an error ...
2
votes
0
answers
136
views
Deserializing generic class with init-only setter in .NET 4.8 throws MissingMethodException
When I try to deserialize a generic class that contains init-only setters, I get the following exception:
System.InvalidOperationException: 'There is an error in XML document (2, 2).'
Inner Exception:...
1
vote
1
answer
191
views
Create XML using XDocument or from XSD schema using xsd.exe and XmlSerializer?
Why use xsd.exe tool to create class for XSD schema and then use serializer to create XML file, when you can use XDocument.
Should I be always using XDocument and manually create the XML document by ...
0
votes
1
answer
55
views
WCF MessageContract not binding to classes - MessageContract is Null in endpoint
I am trying to receive a request in WCF. I need to respond with a MessageContract, therefore I need to take a MessageContract as input. I cannot alter the input SOAP request and must accept it as is....
0
votes
0
answers
183
views
C# How to change XmlSerializer "cultureinfo settings"
I realize this same kind of question has been asked previously by some people. But solutions in those haven't really helped me.
My problem currently is that I have XML messages where for example ...
1
vote
1
answer
69
views
How can I deserialize an array of strings with XmlSerializer?
I'm trying to use XmlSerializer.Deserialize() for my XML file. This is the code:
private void LoadSceneDialogues()
{
if (dialogueXML != null)
{
sceneDialogues = new Dictionary<int, ...
0
votes
1
answer
104
views
Export object to XML file
I have an object like this:
public partial class CableApplication : StateObject
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:...
-1
votes
1
answer
141
views
Symfony Serializer xml with complex xsd type in sequence
i got the following XSD:
<xsd:complexType name="typeADDRESS">
<xsd:sequence>
<xsd:element ref="NAME" minOccurs="0" maxOccurs="unbounded&...
3
votes
0
answers
81
views
XmlSerializer deserialization UnknownAttribute event not firing for built-in types
I have an event handler for XmlSerializer's UnknownAttribute event. This fires correctly if I have the following document:
<Document>
<Test unknown="attribute">
...
...
0
votes
0
answers
97
views
How to deserialize an XML file into a class without using attributes
I've been attempting to perform XML deserialization involving a nested object into a C# class without using attributes. The XML element is "Man," while the corresponding C# class is named &...
0
votes
0
answers
34
views
change order of xmlserialization with inherited class from base class
I have 2 classes. A base class and a extended class that inherit from this base class. When I want to serialize the extended class the order isn't correct.
public class BaseClass
{
[XmlElement(&...
0
votes
0
answers
51
views
Collection attributes are not serialized to xml [duplicate]
I have a custom serializable generic collection, defined (a simplified example) like this:
[Serializable]
public class ArrayOfItems<T> : IEnumerable<T>
{
[XmlAttribute("Setting&...
0
votes
0
answers
59
views
How to serialize abstract classes with a large number of subclasses?
I am trying to serialize a class with a field containing another class, but the field name appears in the XML.
I have the following classes:
public class CustomExpression
{
[XmlAttribute] public ...
1
vote
1
answer
87
views
XmlSerializer - Iterating over branches
I have an xml supplied by an external source. I have no say in their design or function.
I can reach the initial branch and read the values as needed. I fear editing as I can't access any of the other ...
1
vote
1
answer
109
views
C# deserialize known "UnknownElement" from XML
I'm trying to find a simple way to deserialize compile-time known element to [Serializable()] class while reading XML where the elemnt itself is not the member of the class (any more). In short, I'm ...
0
votes
1
answer
87
views
XmlSerializer for XML with hybrid elements
I am trying to use XmlSerializer to serialize/deserialize SyncML. I am having difficulty with the pattern which occurs in the <Get> tag as shown below:
<SyncML xmlns="SYNCML:SYNCML1.2&...
0
votes
0
answers
38
views
Recognize Custom-Null Values in XML during Deserialization
I have an old XML data file:
<tag1>
<subtag1>a string</subtag1>
<subtag2>NIL</subtag2>
<subtag3>14/06/2023</subtag3>
</tag1>
<tag1>
<...
0
votes
0
answers
25
views
How can I selectively return full XML properties in one method and partial in another using the same C# class?
I have a problem with serialization c# in .net
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
Is possible to control ...
0
votes
1
answer
531
views
Symfony serializer - Deserialize xml to array of objects
php Symfony serializer - Deserialize xml to array of objects
How deserialize xml with attributes to array of objects?
$string = '<?xml version="1.0" encoding="UTF-8" ?>
<...
1
vote
2
answers
88
views
C# - How to XML Deserialize a Dictionary<string>, List<string>>?
Here is what I tried but I get this error:
Error CS0029 Cannot implicitly convert type 'ListBoxAndDictionary.CountriesAndCities' to 'System.Collections.Generic.Dictionary<string, System....