serialization

How do I generate a .proto file from a C# class decorated with attributes?

Trying to get my mind around google protobuf. I found some implementation of protobuf in C# but they seems to lack one feature: the ability to generate .proto files automatically from an existing C# class decorated with attributes. The reason I want to do it this way instead of going from auto-generated C# classes from .proto file is be...

Unable to serialize the session state... [Updated!]

I am trying to store some objects in the session (which is using a StateServer), but I am getting the error "System.Web.HttpException: Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode" I know what the error message means, but I can't work out why. All of the classes I am using are marked as Serializable, and...

Is it possible to use Protobuf-Net with a class without a parameterless constructor?

Using Protobuf-Net, I see that it does not seem possible to deserialize a class without having a parameterless constructor or I may be missing something? I don't want some of the classes with a parameterless constructor. Is there some kind of attributes that I could use or some other technique? ...

CSharp/DotNet: Serialization, Generics and base classes

Can someone tell me why this class requires [XmlInclude(typeof(AutoHedgerBaseDataObject))] to deserialize properly? It's not clear to me. [Serializable] [XmlInclude(typeof(AutoHedgerBaseDataObject))] public abstract class AutoHedgerCommandMessage { #region Variables private string myUpdatedBy; private string myUpdatedTime...

Deserializing data from file. Performance issue

I read a table with more than 1 million records from a database. It takes 3 minutes until I have a populated object in memory. I wanted to optimize this process, and serialized this object to a file using binary BinaryFormatter. It created a file with 1/2 GB size. After I deserialized this file back to memory object. This took 11 minutes...

What could cause a failure in PHP serialize function?

I have some serverside PHP code that attempts persist a data object (essentially an multi-dimensional array) to a backend database. This data object originally comes in as AMF actionscript object sent from a flex application. I want persist the object in whole for later use so I have used the php serialize function and encode the object ...

Does BinaryFormatter apply any compression?

When .NET's BinaryFormatter is used to serialize an object graph, is any type of compression applied? I ask in the context of whether I should worry about the object graph having many repeated strings and integers. Edit - Hold on, if strings are interned in .NET, there's no need to worry about repeated strings, right? ...

Serializing Hashset contents to a SQL table

I have a hashset that I want to serialize to a SQL Server table. When serialized hashset looks like this... <InstallerContactIds> <int>153771</int> <int>209572</int> </InstallerContactIds> I am using the following to insert the XML into the table... INSERT INTO dbo.cv_AssessorActionPlanInstallers SELECT @AssessorActionPlanId...

WCF DataContract serialization of read-only properties?

Whenever I use WCF, I always try to make immutable classes that end up going over the wire (i.e. parameters set in constructor, properties are read-only). However, this gets in the way of WCF serialization, which demands that all properties be Public get/set (which makes sense, because it has to deserialize them) Even in this related po...

Passing parameter to delegate function

I currently have this: instance = new Class1<Type1>( "param1", () => new ViewDataDictionary<Type2>( new Class2 { Prop1= CreateList(new List<long> { 234 }), Prop2= CreateList(new long[] { 234 }) ...

Deserializing an RSS feed in .NET

Is it practical / possible to use serialization to read data from an RSS feed? I basically want to pull information from my Netflix queue (provided from an RSS feed), and I'm trying to decide if serialization is feasible / possible, or if I should just use something like XMLReader. Also, what would be the best way to download the feed fr...

GWT and java.io.Serializable

Hello, In my GWT app I have the following model class: import com.google.gwt.user.client.rpc.IsSerializable; public class TestEntity implements IsSerializable { public String testString; } This class implements the GWT custom IsSerializable marker interface - which I really don't like, because I use my model classes not only for...

Does serialization preserve object identity?

I am using the Java Serializable interface and the ObjectOutputStream to serialize objects (until now, this method has been sufficient for my purposes). My API relies on object identity for some operations and I’m wondering if it will be preserved by serialization. That is to say: if, for two arbitrary objects a and b, it holds a == b b...

XmlSerialization problems on compact framework 3.5

Hello, I am doing a finger exercise and trying to write a application that lets my computer and windows mobile phone communicate over bluetooth trough serial port. Now I have ran into a snag with the serialization of objects. Binary seralization is not supported by .Net Compact Framework so I am opting for XmlSerialization. I have writt...

C# Automatic find a Children Class by a Unique ID

Hello! I have about 20 classes for different messages and this number are growing. Each class has a unique ID, so I can transform the class on a byte[] with my own method of serialization and then transform a byte[] again on my class with this uniqueID. All my messages are children of a BaseMessage class that already implements the uniq...

Binary Serialization vs App Settings (user.config)

I am using C# (.Net 2.0) to develop windows application. I need to store nearly 50 to 60 user settings. Can anyone, please, tell which is better of the following? Binary Serialization or Application Settings (user.config) Thank you. ...

Why isn't DataContractJsonSerializer serializing my Id property?

I'm using LINQ-to-SQL for CRUD functionality, and DataContractJsonSerializer to serialize the object to JSON. I am also using ASP.NET MVC's data binding to post values to an MVC action that does the inserting. The problem is that it will serialize all of the properties except the Id property. I've got the model set up as so: [Serializab...

How to control namespace in .NET SoapFormatter?

I am writing some code that needs to be backwards compatible with EXISTING remoting code that is using SOAP to serialize some objects. My difficulty is that I have had to move some objects to new assemblies, so the remoting is broken. For example, I serialize an object using the .NET SoapFormatter like this: Person p=new Person(); str...

Object Serialization and Deserialization?

Hi all. What are Object Serialization and Deserialization? What difference does Serialization have with normal techniques like reading an object's properties and then filling a DataRow's columns with them and finally saving the DataRow in DB ? Thank you ...

DataContractSerializer only partially serializing my objects

I am using the following code to serialize an object to XML, StringBuilder sb = new StringBuilder(); DataContractSerializer dcr = new DataContractSerializer(query.Result.GetType()); XmlWriterSettings xws = new XmlWriterSettings() { CloseOutput = true, Encoding = Encoding.UTF8 ...