Does anyone know if it is possible to prevent calling of a public constructor from outside a range of assemblies?
What I'm doing is coming up with a class library that has XML serializable classes. These classes make no sense if constructed without setting various properties so I want to prevent that state.
I'm wondering if there is a...
I've got a class which uses an XmlSerializer in its Read/WriteXml methods. The Serializer is currently private readonly.
public class Foo : IXmlSerializable
{
private Bar _bar = new Bar();
private readonly XmlSerializer serBar = new XmlSerializer (typeof (Bar));
public void WriteXml (XmlWriter writer)
{
serBar.S...
I have to send information too a third party in an XML format they have specified, a very common task I'm sure.
I have set of XSD files and, using XSD.exe, I have created a set of types. To generate the XML I map the values from the types within my domain to the 3rd party types:
public ExternalBar Map(InternalFoo foo) {
var bar ...
This example uses a StringWriter to hold the serialized data, then calling ToString() gives the actual string value:
Person john = new Person();
XmlSerializer xmlSerializer = new XmlSerializer(typeof(Person));
StringWriter stringWriter = new StringWriter();
xmlSerializer.Serialize(stringWriter, john);
string serializedXML = stringWriter...
My last question was about getting the string representation of an object serialized to XML. One of the responders wrote an extension method to encapsulate the serialization process.
My question now is how can I use an Extension Method to return an array of strings, when passed an IEnumerable<T> object, where each string in the array ...
I'm using XmlSerializer.Serialize, and it produces line breaks and unnecessary spaces. How to avoid it?
...
I recently read the IXmlSerializable interface information on MSDN and was a little confused about the whole end tag thing.
As I understand it, if you are implementing IXmlSerializable then you do not need to write the end tag, but you do need to read it? E.g. the following would error if my class A does not read the end tag
<A>
<i...
I am trying to save a custom object as a user setting in a VB.net app. This object consists of a List(Of Pair(Of String, Object)). Pair is a custom class which has two read/write properties (a String and an Object).
If I put simple types like int, string, datetime as the second value of my pair, the setting is saved without any problem....
In a C# app I am pulling a message off of a SQL service broker queue with the below statement.
When attempting to convert the message_body to SqlBytes and other types an exception is thrown. At runtime message_body always seems to begin as type byte[].
Leaving message_body as a byte[] works but I get an exception complaining of an erro...
I have two classes SccmAction and TicketAction which both implement interface IDelivery. These classes will be transmitted on a processing queue from which I just want to pull the message and act upon the Deliver method.
It seems however that I cannot deserialize to an interface because when I attempt to do so a System.NotSupportedExcep...
I'm writing a windows service application that needs to serialize and deserialize XML documents repeatedly during its execution. As I need to serialize and deserialize generic types that are not known during compilation time (I don't know a priori how many types I need to serialize/deserialize) I'd like to know if it is a good idea do ke...
I spent a good portion of time last week working on serialization. During that time I found many examples utilizing either the BinaryFormatter or XmlSerializer. Unfortunately, what I did not find were any examples comprehensively detailing the differences between the two.
The genesis of my curiosity lies in why the BinaryFormatter is ab...
Hi
I'm testing XML Serialization in my class, but i noticed that the ID number didn't get saved when i ran the program.
So i was looking around and modifying a few things but nothing worked, then i saw that all fields except ID had both get and set properties. So i added a set; property to my ID number and poof it worked.
The question ...
Duplicate: This is duplicate of http://stackoverflow.com/questions/134224/generating-an-xml-serialization-assembly-as-part-of-my-build. Please close it as a duplicate.
How do I get Visual Studio to create and embed an XmlSerializer assembly into an msi during a build? I'm hoping to shave a couple of seconds off my app's startup time.
...
I'm having an issue with deserializing an XML file with boolean values. The source XML files I'm deserializing were created from a VB6 app, where all boolean values are capitalized ("True", "False"). When I try to deserialize the XML, I'm getting a
System.FormatException: The string 'False' is not a valid Boolean value.
Is there a w...
I'm serializing an object that contains HTML data in a String Property.
Dim Formatter As New Xml.Serialization.XmlSerializer(GetType(MyObject))
Dim fs As New FileStream(FilePath, FileMode.Create)
Formatter.Serialize(fs, Ob)
fs.Close()
But when I'm reading the XML back to the Object:
Dim Formatter As New Xml.Serialization.XmlSerialize...
I have this xml snippet as part of a xml file that will be deserialized to a c# object
<EmailConfiguration>
<SendTo>
<Address>[email protected]</Address>
<Address>also send to</Address>
</SendTo>
<CC>
<Address>CC</Address>
</CC>
<BCC>
<Address>BCC</Address>
</BCC>
</EmailConfiguration>
Notice the SendToAddress is a collection ...
I have a class property that is automatically generated by a framework with its appropriate XmlElement attribute. I inherit this class and expose it as a parameter on a webservice, for which a WSDL is auto-magically generated.
I need to replace said property's XmlElement attribute with my own, and have the WSDL generate using my new at...
I'm currently serializing an object using XMLSerializer, and the resulting XML starts with:
<?xml version="1.0" encoding="utf-16"?>
Which I would like to get rid of, because in this particular case I don't need it (I'll only use the serialized string to deserialize later with my own code, so I can re-add it later when needed).
I'm al...
I am using XML serialization to read a large user input file. If there is a semantic error in the input that is not discovered during reading, I'd like to be able to tell the user where (file, line, column) they can find the offending element. Is this possible with XML serialization?
CLARIFICATION: The code in question is an IoC conta...