serialization

Efficient way to store hash in a file

HI, I am implementing some unix userland tool, that needs to store hash on the disk. The hash will be read every run of a program, pretty frequently. To give you better insight, the hash needs to store "name:path" values only. I looked at bdbd module for python, but I can see it will be deprecated in Python 3. Also saw Pickle. Im not ...

WPF loading serialized image

Hi, In an app I need to serialize an image through a binarywriter, and to get it in an other app to display it. Here is a part of my "serialization" code : FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write); BinaryWriter bin = new BinaryWriter(fs); bin.Write((short)this.Animations.Count)...

Disable Type Hinting in WCF JSON Services

I have what should be a relatively simple question that I can't seem to find an answer for. When WCF performs its serialization of objects, it automatically applies Type Hinting. For Json services, this results in an extra field on each complex object called __type. An object defined as: [DataContract] public class SomeObject { [Da...

How can I set known type for IEnumerable<T>?

For WCF I need to specify that the known type for any IEnumerable<T> is T[]. Is there any way that this is possible using the configuration section? Something like the following, though I know it doesn't work just like this: <system.runtime.serialization> <dataContractSerializer> <declaredTypes> <add type="System.IEn...

AppFabric Caching - What are its serialization and deserialization requirements for an object?

Problem: When caching an instance of a class and immediately getting it back out of cache, i get the object back (its not null), but all of its properties / fields are null or defaults. _cacheHelper.PutInCache("testModuleControlInfoOne", mci); //mci has populated fields var mciFromCacheOne = _cacheHelper.GetFromCache("testM...

Serializing IronPython Objects Which Inherit From CLR Types

This may be a bit of a weird question, but is there any reliable way to serialize IronPython objects whose classes extend CLR types? For instance: class Foo(System.Collections.Generic.List[str]): def Test(self): print "test!" System.Collections.Generic.List<string> is serializable with Pickle, as it implements the ISerial...

Deserializing "old" xml into new class instance

I've had a class which looked like public class MyClass { public string EmployerName; public string EmployerSurname; public string EmploeeName; public string EmploeeSurname; } I've refactored the code above to this: public class MyClass { public MyClass() { Employer = new PersonInfo(); Emploee ...

Benefits of [NonSerialized] when [Serializable] is not used.

I'm looking through some existing code in a project I'm working on, and I found a class that is implemented as: public class ThingOne { private int A; private int B; [NonSerialized] private System.Timers.Timer timer1; } Shouldn't it look more like this? [Serializable] public class ThingOne { private int A; ...

Elegant way of doing interlanguage data exchange

I have a socket server which I am writing in C++ and a client which I have written in C#, now I want to send messages between them. I was considering de-serializing 'message' objects to xml and creating object instances across the wire and it looks like a elegant way to do things rather than string/xml parsing but I am open to new ideas,...

Convert a variable length struct to byte[]

I'm trying to send a network packet of data to a hardware device. I would like to use a slick, object oriented approach so I can work with it at a high level. The packet has several fields of variable length. Obviously the byte layout is very particular. Here's a struct representing the packet I need to send: [StructLayout(LayoutKind.S...

Java de-serialization of enums and valueOf

I've got a distributed system with a serializable enum class with constants that might vary across the system. Because these classes may be different, valueOf could potentially be called upon deserialization on a constant that doesn't exist, throwing a runtime exception. I don't believe valueOf can be overridden, or another method cu...

type to int mapping

I have two c++ programs that need to have a map type -> int that is known at compile time and equal between the two programs. Furthermore, I'd like to automatically make sure at compile time that the map is one-to-one. How would you solve that? (c++0x-extensions are allowed). The first part is easy: Share a template < typename T > stru...

How do I sensibly store large numbers of serialized binary files in C#?

I'm serializing a large number of objects to binary files, however I want to keep everything neatly organized and don't really want hundreds of files in a folder. Is there anyway to group them into zip files, and then access the individual files within that zip? For example, say I created 100 binary files and zipped them. Would I be abl...

Weird problem with jquery serialize: data get cut in certain circumstances

I'm using serialize in .post request and it looks like this $.post(this.action, $(this).serialize(), null, "script"); In the form there is a textarea with the name 'comment'. The problem is that when I put first string in double quotes, followed by end line and then some text server recieves only first string without quotes. For i...

How would you serialize a large array with 10^9 values?

This throws an out of memory exception when using 10^8 items but not with 10^7. How would you serialize an array with 10^9 values in it so that it could be stored in a database? Dim List((10 ^ 9) - 1) As Int64 For i = 1 To (10 ^ 9) List(i - 1) = i Next Dim Format As New Runtime.Serialization.Formatters.Binary.BinaryFormatter Dim Wr...

how to serialize json when the value changes from int to array + order may change

I'm not sure how to serialize the following example from json to a c# object. Normally, I do something like this: JavaScriptSerializer ser = new JavaScriptSerializer(); result = ser.Deserialize<Library.Libraries.Model.Post>(responseFromServer); But in this case, I'm not sure how to create the class to base it off since the values an...

Android: com.sun.org.apache.xerces.internal.dom: classNotFoundException

Hi. I am developing an android application at the moment, and i'm facing a problem that i have no idea how to solve. My application communicates with a Tomcat Server, and i'm using ObjectOutputStream to send a Document object to my application from my servlet. There fore, i'm importing org.w3c.dom to my project. The problem i'm facing is...

Socket's input byte stream wrapped in two different stream types?

I'm trying to implement such a protocol: Client side: 1) client sends command (String) 2) client sends object 3) client receives object or data [depends on command] Server side: 1) server reads command (String) 2) server receives object [type depends on command] 3) server sends object or data [depe...

Winforms designer is unable to find the project assembly?

I have a win forms Usercontrol that is suddenly unable to build, with this error: Edit- forgot to mention, The name of the project is Datatesting, it is not an external reference! Error 1 Invalid Resx file. Could not load type DataTesting.TableColumn, DataTesting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null which is used ...

WCF: Serialization? Streaming?

Hi guys, I need to understand how does WCF works when sending a message. Does WCF serialize everything before sending it? My other question is which will be the benefit of using Streaming? Is it better for bigger messages, lets say between 1Mb to 2Mb? Can I send a complex object serialized, and then be able to deserialize it in the oth...