serialization

Gratuitous use of System.Runtime.Serialization attributes?

Is there any cost/drawback (apart from typing too much) to adorning a class with System.Runtime.Serialization attributes (like [DataContract]) such that it can be used locally as a direct reference to a desktop Client project or as a type for a WCF service? The goal here is to write a data-tier class that can be used in both rich client ...

DataContractSerializer vs XmlSerializer: Pros and Cons of each serializer

My desktop application serializes objects using XmlSerializer. I was suggested to leverage DataContractSerializer instead. Under which scenarios should I use DataContractSerializer? Many thanks Comments. 1. The output XML file is stored locally. No other applications deserialize objects from that XML file. 2. My application runs with ....

C#: What is the best collection class to store very similar string items for efficient serialization to a file

Hi, I would like to store a list of entityIDs of outlook emails to a file. The entityIDs are strings like: "000000005F776F08B736B442BCF7B6A7060B509A64002000" "000000005F776F08B736B442BCF7B6A7060B509A84002000" "000000005F776F08B736B442BCF7B6A7060B509AA4002000" as you can notice, the strings are very similar. I would like to save these ...

How to create javascript object from form elements using jQuery

I'd like to be able to create a javascript object from my html form and am wondering if there's a good way to do this using jquery. I guess what i'm looking for is something similar to $.serialize, but which would result in a map instead of a string. <form> <input type="text" name="foo1" value="bar1" /> <input type="text" name="foo...

Deserializing a struct with SoapFormatter

I added a new member to an existing class that's serialized. The SoapFormatter was used on released versions, so this can't be changed. The main problem is deserializing old versions that don't have this new member. The new problem is when ISerializable is added to the class, structs in that class can no longer be deserialized. I get...

XmlSerializer equivalent of IExtensibleDataObject

With DataContracts you can derive from IExtensibleDataObject to allow round-tripping to work without losing any unknown additional data from your XML file. I can't use DataContract because I need to control the formatting of the output XML. But I also need to be able to read a future version of the XML file in the old version of the app...

Android serialization: ImageView

I have a simple class: public class Ball2 extends ImageView implements Serializable { public Ball2(Context context) { super(context); } } Serialization ok: private void saveState() throws IOException { ObjectOutputStream oos = new ObjectOutputStream(openFileOutput("data", MODE_PRIVATE)); try { ...

"Ambigous type variable" error when defining custom "read" function

While trying to compile the following code, which is enhanced version of read build on readMay from Safe package. readI :: (Typeable a, Read a) => String -> a readI str = case readMay str of Just x -> x Nothing -> error ("Prelude.read failed, expected type: " ++ (show (typ...

Are arrays stored as a pointer or in their entirety inside C struct's? (was: How to dump structs to disk when some fields are pointers?)

Hello, I'm writing a FUSE plugin in C. I'm keeping track of data structures in the filesystem through structs like: typedef struct { block_number_t inode; filename_t filename; //char[SOME_SIZE] some_other_field_t other_field; } fs_directory_table_item_t; Obviously, I have to read (write) these structs from (to) disk at som...

Deserializing JSON with JavaScriptSerializer C#

I am experimenting with JavaScriptSerializer to deserialize some JSON in C#, and have a couple of questions regarding the use of DataMember. I want my DataContract class to have a property called "Parts" that maps to a JSON object "rings". If I set the DataMember Name="rings" and name the property "Rings" everything works as expected....

Default entries on a first time creation for a serialized class

I have a class I am using for serializing various configuration options for an application I am working on. I'm adding a new property to the class that is a List, and I'd like it to fill this list if it does not exist already in a XML file. My first thought was to check if the list contained zero items, however this is not acceptable bec...

AS3 serialization of Vector of custom objects

What is serialization support like for the new Vector class? I have a Vector.<GameMove> which I'd like to serialize into a ByteArray. GameMove is a custom class. I presume it's necesssary to call registerClassAlias() on GameMove, but do I also have to register Vector.<GameMove>? It's it it's own distinctive type, or is it kinda composed...

XAML Serialization object not using asp.net shadow copy

Hi, I'm having a problem where i use the XAML serializer / deserializer for a configuration type file that i have. The problem that i'm getting, is that the XAML serializer is returning objects from the assembly in the /Bin directory, while the rest of the web application is using assembly's stored in the ..../Temporary Files/.. direc...

Serializing ActiveRecord objects without storing their attributes?

I'm working on a problem where I need to store serialized hierarchies of Ruby objects in the database. Many of the objects that will need to be saved are ActiveRecord objects with a lot of attributes. Instead of saving the entire objects and then refreshing their attributes from the DB when I load them (in case they changed, which is l...

How can i see cookie folder

Hi there When i serialize a value and stored in a cookie, i can see cookie text file in Cookies folder. But if i dont serialize that value, i can't see cookie text file. There is my code: (Serialize) BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, "111"); byte[] bArr = ms.ToA...

Which types cannot be used for WCF?

I know for a matter of fact that Type cannot be used when passing in to a WCF service. Does anyone have a complete list? ...

XMlSerialization is not serializing a Datetime

When I serialize an object which has a DateTime in it this is returning empty in the XML string. Please see below for my XSD, serializable class generated from the XSD, and serialization helper class which handles the serialization of the XSD. XSD: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="test" xmlns="" xmlns:xs="ht...

In C# how can I serialize a List<int> to a byte[] in order to store it in a DB field?

In C# how can I serialize a List<int> to a byte[] in order to store it in a DB field? I know how to serialize to a file on the disk, but how do I just serialize to a variable? Here is how I serialized to the disk: List<int> l = IenumerableofInts.ToList(); Stream s = File.OpenWrite("file.bin"); Binar...

Data Contract Serialization Not Working For All Elements

I have an XML file that I'm trying to serialize into an object. Some elements are being ignored. My XML File: <?xml version="1.0" encoding="utf-8" ?> <License xmlns="http://schemas.datacontract.org/2004/07/MyApp.Domain"&gt; <Guid>7FF07F74-CD5F-4369-8FC7-9BF50274A8E8</Guid> <Url>http://www.gmail.com&lt;/Url&gt; <ValidKey>true</Valid...

.Net Remoting: Serialize Object and implementation

Hi, In my scenario there is a client-side assembly that contains a class (Task). This class implements an interface (ITask) that is known on the server. I'm trying to send a Task object from client to server without copying the assembly of the client manually to the server. If I just serialize the task object, the server obviously comp...