serialization

Using NetDispatcherFaultException in OnDeserializing event

I have converted my asmx web service to a wcf service. I have some datatmembers in my datacontract which are to be marked as IsRequired. Now, if the client does not provide me with the required element value, the wcf service throws a System.ServiceModel.Dispatcher.NetDispacherFaultException. But I want to throw a custom error message to ...

GWT serialization - client to server side

Currently working on GWT application and I was wondering how can I serializes an object on client-side and then save that to a file on the server and then be able to dematerialize that file when needed back down on the client. I have read googles documentation on serialization and RPC's seem to be lacking any really examples. A simple go...

polymorphism in c and buffers

I have this union: typedef union Message { message_base base; message_with_parameters parameters; reply_message reply; buffer_t *buffer; // can't figure out what to put here } message; message_with_parameters has a message_base as the first field and reply_message has a message_wit...

Using XML decorations to specify default values during de-serialization

I have a problem deserializing some XML; the XML supplied by a third party is quite verbose, so if there is no value set for an particular element, it will supply and empty element (e.g. <element1 />). This is a problem for certain elements, for example, those that are meant to store integers. I have control over the third party, so I c...

How to determine which classes are serializable

I am changing my ASP.NET app to use a web farm. To do this, I need to change the session state from in-proc to a State Server. To do this, it is my understanding that the classes that are used must be marked as serializable. How can you tell if that is possible with a class? Will you get an error at compile time if it is not possible...

Is there any way to xml serialize an anonymous type in .net using C#

Is there any way to serialize an anonymous type in .net? Normal XmlSerializer fails because the type has no parameterless constructor defined; and NetDataContractSeralizer fails becuase we can't tag DataContract or Serializable attribute to anonymous class. So is there any clever way around or we just can't do it? ...

.NET: Serialize objects into transactional environment

I need a way to serialize objects in a transactional context. Given the following pseudo-code: transation.Begin() try{ serializeObj(obj1); serializeObj(obj2); serializeObj(obj3); } catch(Exception){ transaction.RollBack(); } transaction.Commit(); I want that, after this code runs, or all the objects had been serialize...

Storing binary objects in SQL Server with LINQ

I'm trying to do the same thing as in this question, but am having problems. Can you share with me how you prepared your objects prior to inserting and updating the database? I have a List<myObject> that I want to store as a VarBinary(max) in SQL Server 2008. ...

Inherit from abstract class in WCF without exposing that class

I have various classes which I want to expose as Complex Types in WCF, so I add [DataContract] and [DataMember] attributes as necessary on those types and properties. However if I want to have them inherit from an abstract base class (for example Person inherits from abstract EntityBase), I get an error that the type "cannot inherit fro...

Deserializing legacy (binary) file after refactoring.

I'm attempting to re-organize my application's namespace hierarchy, so I'm using a System.Runtime.Serialization.SerializationBinder sub-class to attempt to handle the renaming. (Most of my renamed classes are correctly deserialized into their new namespaces without problems.) The problem I have is that one of my serialized classes (whi...

How does BinaryFormatter.Deserialize create new objects?

When BinaryFormatter deserializes a stream into objects, it appears to create new objects without calling constructors. How is it doing this? And why? Is there anything else in .NET that does this? Here's a demo: [Serializable] public class Car { public static int constructionCount = 0; public Car() { construction...

wcf serialization problem

I have a type MyParameter that i pass as a parameter to a wcf service [Serializable] public class MyParameter : IXmlSerializable { public string Name { get; set; } public string Value { get; set; } public string Mytype { get; set; } #region IXmlSerializable Members public System.Xml.Schema.XmlSchema GetSchema() ...

Deserializing xml with dynamically loaded assembly

Hello, I have a problem with xml-deserialization and dynamically loaded assemblys. I load my assembly directly from a zip-file to a byte array. Then i load this assembly. The assembly contains a data-model, which should be deserialized with XmlSerializer. The problem is that I always get an TypeInitializationException, if i try to load ...

Is any rule to detect that object is serializable in C#?

Possible Duplicate: How to check if an object is serializable in C# Recently found the following sentence: "Just to enhance, take a thumb rule, the object that support .ToString() are all serializable objects." This looks like strange as all objects have .ToString() method so in this case all objects must be serializ...

Why is my List<T> not being serialized?

This relates to this question, but this time I'm trying to work out how to serialize the dictionary. I have a class that inherits from Dictionary that I need to be able to serialize. The Serialization methods look like this, basically the values collection from the dictionary are added to the list, which is serialized. [Serializable] p...

BinaryFormatter alternative

I am shopping for a BinaryFormatter alternative/replacement. The current issues I have with BinaryFormatter (and the alternatives should address this) are 1) backwards compatibility (can deserialize Classes serialized using an earlier version) 2) size 3) speed I have checked out AltSerializer which looks ok, some conflicting re...

How to rebuild my class hierachy with Json.NET?

I have a simple class hierachy. Foo is the base class. Bar and Baz are inherited from Foo. Instances of these classes are stored in a List. I have to serialize the list to JSON. It works pretty well. But the problem is deserialising it back into a List<>. I put Foos, Bars and Bazs in the list, serialize it and when I deserialize it I ge...

C# - Error passing object to web service

I already searched a lot in Google. I created a EntityClass on client side, and then I added the library reference of this class on Web Service side. But when I want to call the method, it shows this error: Error 2 Argument 1: cannot convert from 'Services_Library.UserService.UserServiceSoapClient' to 'Services_Library.UserService.Us...

C# - Is it possible to pass an object to a web service without explicity serialization?

Possible Duplicates: C# - How Can I Pass an object to a web service? C# - Error passing object to web service If possible, how? ...

XmlSerialization throwing error when deserializing?

I am trying to serialize an object into the database using xml serialization, however when deserializing it I am getting an error. The error is There is an error in XML document (2, 2) with an inner exception of "<MyCustomClass xmlns=''> was not expected." The code I am using to serialize is: public static string SerializeToXml<T>(T ...