xmlserializer

XmlSerializer's functionality in PowerShell?

Is there a way to leverage the functionality of .NET's XmlSerializer class in PowerShell? More specifically, the ability to easily de/serialize .NET types into Xml e.g. XmlSerializer s = new XmlSerializer(typeof(MyType)); TextReader r = new StreamReader("sample.xml"); MyType myType = (MyType)s.Deserialize(r); r.Close(); I know I can ...

.NET OutOfMemoryException on XMLSerializer.Serialize

I have a web site that is throwing OutOfMemoryExceptions on whenever it gets to the following spot in my code: XmlSerializer xs = new XmlSerializer(t, xoverrides); Seeing how this only happens when it is on the web server, i don't have a ton of information on why this is happening. I know that the objects that it is serializing aren't...

How to generate tag prefixes using XmlSerializer

I wanted to generate the following using XmlSerializer : <atom:link href="http://dallas.example.com/rss.xml" rel="self" type="application/rss+xml" /> So I tried to add a Namespace to my element : [...] [XmlElement("link", Namespace="atom")] public AtomLink AtomLink { get; set; } [...] But the output is : <link xmlns="at...

OutOfMemoryError calling XmlSerializer.Deserialize() - not related to XML size!

This is a really crazy bug. The following is throwing an OutOfMemoryException, for XML snippits that are very short and simple (e.g., <ABC def='123'/>): public static T DeserializeXmlNode<T>(XmlNode node) { try { return (T)new XmlSerializer(typeof(T)) .Deserialize(new XmlNodeReader(node)); } catch (Ex...

C# System.Xml.Serialization Self-nested elements

Hi, I am trying to deserialize <graph> <node> <node> <node></node> </node> </node> <node> <node> <node></node> </node> </node> </graph> with [XmlRoot("graph")] class graph { List<Node> _children = new List<node>(); [XmlElement("node")] public Node[] node { get { return _children.ToArray(); } ...

axis2 maven example

I try to use axis2 (1.5.1) version to generate java codes from wsdl files, but I can't figure out what is the correct pom.xml <build> <plugins> <plugin> <groupId>org.apache.axis2</groupId> <artifactId>axis2-wsdl2code-maven-plugin</artifactId> <version>1.5.1</version> <execution...

Can I swap WCF deserializer from configuration?

I have a problem with WCF deserialization where the client hangs on the response for more than a minute. I'd like to try to swap different deserializers and see if it affects the behavior. Can I swap in/out different serializers (are there any others?) from configuration, and if so can I do that with any binding, or is that out of cont...

Why doesn't XmlSerializer support Dictionary?

Just curious as to why Dictionary is not supported by XmlSerializer? You can get around it easily enough by using DataContractSerializer and writing the object to a XmlTextWriter, but what are the characteristics of a Dictionary that makes it difficult for a XmlSerializer to deal with considering it's really an array of KeyValuePairs. ...

How to send a XmlSerializer Class to a WebService and then Deserialize it?

Hi! I want to be able to send a XmlSerializer class (which is generated obvious in remote C# application) over a WebService that will then deserialize it into a class. (I didnt know it its possible either) My class is: SystemInfo I'm serializing it this way: XmlSerializer mySerializer = new XmlSerializer(typeof(SystemInfo))...

XmlSerializer one Class that has multiple classes properties

Hi there! Objective: Serialize all the public properties of the ClassMain: public class ClassMain { ClassA classA = new ClassA(); public ClassMain() { classA.Prop1 = "Prop1"; classA.Prop2 = "Prop2"; } public string Prop1 { get; set; } public string Prop2 { get; set; } public ClassA ClassA ...

How do I stop and empty tag in XML serializer?

I have an object like this, public class UserObj { public string First {get; set;} public string Last {get; set;} public addr Address {get; set;} } public class addr { public street {get; set;} public town {get; set;} } Now when I use XmlSerializer on it and street and town are empty I get this in the XML outp...

How can I stop XmlSerializer transforming &#234; to &amp;#234; in an attribute?

I have the following DOM <row> <link href="B&#252;ro.txt" target="_blank"> my link </link> </row> When I serialize it to a file using the Java XmlSerializer it comes out like this: <row> <link href="B&amp;#252;ro.txt" target="_blank"> my link </link> </row> Is ...

F# Add Constructor to a Record?

Basically I want to have a single construct to deal with serializing to both JSON and formatted xml. Records worked nicely for serializing to/from json. However XmlSerializer requires a parameterless construtor. I don't really want to have to go through the exercise of building class objects for these constructs (principle only). I w...

IDeserializationCallback in XMLSrializer...

Is there a way to utilize the IDeserializationCallback interface with the standard xmlSerializer? It does not appear to be supported in this context. IDeserializationCallback works fine when used with the binary formatters. Basicaly i want to do some calculation when de-serialization e.g.: public void IDeserializationCallback.OnDeser...

How to make a custom TypeConverter for a given type with XmlSerializer?

The question is how to create a custom TypeConverter for a type such as Boolean when de/serializing Xml in C#? <Root> <Flag>True</Flag> </Root> Currently this does not work because the value 'True' has a capital letter. I want the TypeConverter to take care of converting value to a Boolean. I know there are a couple ways to achiev...

XMLSerializer failing save/load when called from an assembly dynamically loaded from parent application?

Hey all, I am writing a plugin dll for an application. The application loads plugin assemblies via: assembly = Assembly.Load(System.IO.File.ReadAllBytes(filename)); The problem manifests itself when I attempt to serialize/deserialize a plublic class. I narrowed it down to the serialization of: public BindingList<MyClass> MyClasses ...

XmlSerializer and nullable attributes

I have a class with numerous Nullable<T> properties which I want to be serializable to XML as attributes. This is apparently a no-no as they are considered 'complex types'. So, instead I implement the *Specified pattern, where I create an addition *Value and *Specified property as follows: [XmlIgnore] public int? Age { get { return...

Serializable dictionary, how to set key name ?

Question: I use a serializable dictionary class, found at http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx , to serialize a dictionary. Which works fine, but I run into an annoying problem. <System.Xml.Serialization.XmlRoot("DataBase")> _ Public Class cDataBase <System.Xml.Serialization.XmlNamespaceDecl...

WCF Data Contract / Serialization

I created a simple WCF application which expose one operation. This operation takes a composite data type as parameter. I have not decorated this composite data type with [DataContract] attribute. But this is working and I can see the Schema for this in WSDL. Now my understanding is that this new custom type should be decorated with ...

XmlSerializer throws InvalidOperationException when having a namespace prefix in the attribute

I try to read an XML file that contains the following element: <ho:CODED-TYPE ho:BASE-DATA-TYPE="A_UINT16" CATEGORY="STANDARD-LENGTH-TYPE" ENCODING="UNSIGNED"> My class to describe this node looks like that: public ref class FIBEXCodedType { public: [XmlAttribute("ho:BASE-DATA-TYPE")] property String^ BaseDataType; [XmlAttr...