datacontractserializer

Getting bad generated code from "Update Service Reference"

In VB.NET (using Visual Studio 2008) my WCF service has an interface something like: <ServiceContract()> _ Public Interface IThingService <OperationContract()> _ Function GetThingByNumber(ByVal thingNumber As MyKeyClass) As Thing <OperationContract()> _ Function GetThing(ByVal thingId As Guid) As Thing ' ... End Inter...

DataContractSerializer XML double the size of XML serializer output - Is this really faster and more scalable?

I'm upgrading a restful service, and am now using the DataContractSerializer to output the response. The previous version just used custom serialization w/ XmlSerializer. Because that version used attributes a lot, and DCS never does, I'm seeing that the new response size is 1.5x the size of the previous version when compressed with gz...

BOM encoding for database storage

I'm using the following code to serialise an object: public static string Serialise(IMessageSerializer messageSerializer, DelayMessage message) { using (var stream = new MemoryStream()) { messageSerializer.Serialize(new[] { message }, stream); return Encoding.UTF8.GetString(stream.ToArray()); } } Unfortuna...

How to speed up serialization and transport for large object graphs; WCF 3.5 & SL3

I have a 3.5 SP1 project, WCF service which is limited to consumption by Silverlight 3 clients. Due to the business requirements we have to work with large object graphs that are hydrated via SQL Server on the WCF side and then sent to the Silverlight client. They are deep, you might have a class that has two collection properties and ea...

DataContractSerializer, EmitDefaultValue and empty tags

I'm working on getting some objects serialized through an mvc site and returning things via xml, json, etc and I'm looking for the best way to not send the empty elements. In a perfect world, simply attaching EmitDefaultValue:=False to DataMembers in a DataContract would suffice, but in some situations, it just doesn't fly. A String de...

Silverlight serialisation/deserialisation problem

I'm looking for a way to persist Silverlight objects to a user's PC, then re-hydrate them so the user can finish editing them. Serialising with DataContractSerializer and persisting to IsolatedStorageFile works fine. However, deserialising causes a problem. Here's the code that causes the failure: private string _FirstNames = string.E...

WCF: return only necessary properties on json

Because of performance tuning I would like to return only necessary properties. Is there a possibility/workaround? Pseudo / sample code to understand: [DataContract] public interface IMemberOverview { [DataMember] public int Id { get; set; } [DataMember] public string Name { get; set; } } [DataContract] public interfac...

Ignore field order in DataContractSerializer

When deserializing, DataContractSerializer requires not only that an element name matches, but also that it is in a certain order with respect to the other elements. My application is such that every field can be uniquely identified by its name. I would therefore like it to be possible for the XML file to contain the elements in any ord...

Simple data file versioning with DataContractSerializer

Having read Data Contract Versioning we concluded that it's not really the whole story. For example, what happens if you used to have ValueA, and in the new version it's now called ValueB and is of a different type, and you need to convert ValueA to ValueB? There are some callbacks I could use to help with this, but it doesn't look like...

Analysing an XML serialized object graph to find out what takes up most space

We have a some objects that are exposed by WCF services (using wsHttpBinding) and serialized into XML. Here is an extract of one of them: [DataContract] public class Person { [DataMember] private string _forename; [DataMember] private string _middleInitial; [DataMember] private string _surname; [DataMember] private List...

DataContractSerializer C# Can serialize, cannot deserialize, why?

Hi, I have application created using WCF and C#, it's architecture requires to add KnownTypes through App.config. I have services going like this: Client -> CentralServer -> DataServer (where -> is WCF connection) Now, I've added KnownTypes to both CentralServer App.config and DataServer App.config this way: <add type="Odra.Server.Ce...

DataContractSerializer sensitive to order of XML??

I have the following serialized XML: DataDescriptor <d5p1:TimePastToInitializeData > <d5p1:Hours>2</d5p1:Hours> <d5p1:Minutes>10</d5p1:Minutes> <d5p1:Seconds>5</d5p1:Seconds> </d5p1:TimePastToInitializeData> <d5p1:PollRate > <d5p1:Hours>2</d5p1:Hours> <d5p1:Mi...

DataContractSerializer does not properly deserialize, values for methods in object are missing

My SomeClass [Serializable] [DataContract(Namespace = "")] public class SomeClass { [DataMember] public string FirstName { get; set; } [DataMember] public string LastName { get; set; } [DataMember] private IDictionary<long, string> customValues; public IDictionary<long, str...

XSLT Transform XML with Namespaces

I have some XML that I am trying to transform to HTML using XSLT, but I can't get it to work for the life of me. Can someone tell me what I am doing wrong? XML <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.test.com/"&gt; <Brokerage> <BrokerageID>91</BrokerageID> <LastYodleeUpdate>0001-01-01T0...

Error using WCF and DataContractSerializer

I have a fairly complex object model that I'm trying to serialize using WCF. I'm running into a problem where I can create a new instance on the server and return it to the client, then trying to pass that same object back or even serialize it using the DataContractSerializer throws an exception. Test method Server.Service.Test.Seriali...

DataContractSerializer with Multiple Namespaces

I am using a DataContractSerializer to serialize an object to XML. The main object is SecurityHolding with the namespace "http://personaltrading.test.com/" and contains a property called Amount that's a class with the namespace "http://core.test.com". When I serialize this to XML I get the following: <ArrayOfSecurityHolding xmlns:i="htt...

Problems with DataContractSerializer - how to correctly serialize objects deriving from List<T>?

Dear ladies and sirs. Observe the following sample code: namespace A { [Serializable] internal class ComplexObject<T> : List<T>, IEquatable<ComplexObject<T>> where T : IEquatable<T> { private T m_state; internal T State { get { return m_state; } set { m_state = value; } } public bool Equals(C...

How to get data serializer used by WCF operation in runtime

Hi, Is there a chance to get a data contract serializer used by operation (DataContractSerializer/NetDataContractSerializer/XmlSerializer etc) in runtime (for instance using operation behaviour). What I want to achieve is to create some diagnostic code that would serialize messages (in message inspector) using currently attached seriali...

Serializing object with no namespaces using DataContractSerializer

How do I remove XML namespaces from an object's XML representation serialized using DataContractSerializer? That object needs to be serialized to a very simple output XML. Latest & greatest - using .Net 4 beta 2 The object will never need to be deserialized. XML should not have any xmlns:... namespace refs Any subtypes of Exception an...

C# DatacontractSerializer over Sockets multiple root elements

I am writing a Sivlerlight Chat application using Sockets and the DataContractSerializer. I have a class hierarchy of serializable objects with the definitions shared between the Silverlight Client and the C# Server. When a buddy logs on they send a message to the server and if they are verified they are sent an acknowledgment follow...