serialization

"Binary stream does not contain a valid BinaryHeader" error on (de)serialization?

hi I am created a post before " Object to byte not working " . I fixed problems that users said me , but there is still problem . Error Message : The constructor to deserialize an object of type 'WindowsFormsApplication1.Form1+Item' was not found.; void start() { Item item = new Item(); item.files.Add(@"test"); byte[] b = Objec...

C# - Serializing Custom Dictionary<TKey,TValue> Object & TValue SubObjects

Questions - (Relative Code Below) I have a custom class which is a BindableDictionary(). I want to make it serializable. How would I Serialize this? Thoughts Will The serialization still work if the TValue of the BindableDictionary is a custom object that has another BindableDictionary as a property? So my question is, will both th...

How do I use a @serializable scala object?

I know that you can mark a scala object as @serializable, but I don't understand what to do with the object afterwards. Do I simply treat it as a Java Serializable object? I want to serialize the object into a stream of bytes. Can someone show me the code to transform a serialize object into either a byte array or a string? (the goog...

Can you override the stream writers in scala @serializable objects?

I now understand that scala @serializable objects can be used the same as a Java Serializable object. In a Java Serializable object there are methods you can override to change how the object streams: writeObject(ObjectOutputStream) / readObject(ObjectOutputStream). Can you override or inject methods into a scala @serializable object ...

ScriptIgnore in Linq-to-SQL

I have a Linq-to-SQL entity that I will be serializing and returning as JSON over a webservice call. There is one property on that entity that I would like not to be serialized. For this, there is generally the [ScriptIgnore] attribute, which works exactly the way I want if I manually add that to the designer.cs file. Now, since the de...

How to persist application model

My c# application needs to persist its model classes to disk. Initially I tried to do xml serialization. However when I do breaking changes in my model (split one class to two) the saved xml will not deserialize (which is understood). I thought about applying xslt to upgrade the xml but the xml generated is really complex. Is it a good...

Deserializing json array using gson

Continuing from this question. I'm having trouble deserializing the following json array (Sorry for the size): "geometry": { "type": "Polygon", "coordinates": [ [ [ 771230.894373, 4422896.962001 ], [ 804804.852796, 4451159.130080 ], [ 876828.563339, 4417873.954498 ], [ 959794.979827, 4430944.287708 ], [ 910992.515063, 4372980.866944 ...

Implementing our own serializers in C# - tips and gotchas

We probably need to write our own serializers for the classes in our (largeish) C# app - BinarySerializer is too slow and verbose, and protobuf-net has problems with interface-based properties (of which we have loads). Does anyone have any good tips and/or warnings? I suspect we should be using BinaryWriter and BinaryReader, but we hav...

How to serialize two object with `one-to-many` relationship?

I have two classes: Lookup and LookupItem that Lookup has a member named Items that is a collection of LookupItems. I'm not able to serialize Lookup or LookupItem. With the first I get error The type LookupItem was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. and with the secon...

Database Storage of Dynamic Methods in C#

How can I store C# methods in a sql server instance to be loaded and run dynamically (at runtime) at a later date? I am about to begin a production test project at work where I would like the appropriate test methods for the product to be loaded at runtime. I have looked at Reflection.Emit DynamicMethod briefly but it is not serializab...

Converting Serialized Java Classes Between XML and Binary

I am using Java native serialization along with a dynamic proxy to save the parameters and returns of a series of method calls to a file. I would like to convert the binary file that is generated to and from XML. Is this something that I will need to reinvent, or are there already tools out there that can do this? ...

writing many java objects to a single file

how can I write many serializable objects to a single file and then read a few of the objects as and when needed? ...

Scala socket cannot write to output stream

Hi, I'm new in the scala world, so excuse my trivial question. :) I just want to open a socket to a port and sand and receive messages. If I receive a HELO, I want to react with a message, but I'm not able to write to the socket in any way. I used nc to listen for incoming connections: nc -k -l 127.0.0.1 3333 When the client is conne...

how to reattach singleton Spring beans upon deserialization

I want to reinject singleton-scoped dependencies into prototype Spring beans, after they have been deserialized. Say I've got a Process bean, which depends on a Repository bean. The Repository bean is a scoped as a singleton, but the Process bean is prototype-scoped. Periodically I serialize the Process, and then later deserialize i...

Deserialization of arrays of custom type in OSGi

Hello, I'm trying to send objects from bundles over a dedicated communication bundle to an other framework. For communication I use Java standard serialization (with ObjectStreams) over TCP/IP. Communication flow is the following: A sender-bundle will pass serializable objects to a transmit-sender which will serialize the objects and ...

DataContractSerializer problem with events/delegate fields

On my WPF application, I am using DataContractSerializer to serialize object. I observed that it fails to serialize the types that has got an event or delegate declaration. Consider the following failing code: [Serializable] public abstract class BaseClass { public string Name { get; set; } public event PropertyChangedEventHand...

Use JavaScriptSerializer to produce object with arbitrary property names.

In .Net, I want to generate a json object as follows: {"1":true} Can I do so using JavaScriptSerializer? Can I do it any other way? ...

How can I override deserialization in C#

I've got a class that will undergo certain version changes over the course of time. The data from inside this class is serialized and deserialized as part of the startup of my application. The problem I have is if I update the class by adding more properties, and then start the application, the old data does not get loaded properly. What...

Serialization of objects and fatal error

Can anyone explain me, why in the session in this case we get the object with 2 properties? set_error_handler('my_error_handler'); session_start(); $obj = new myclass(); $_SESSION['obj'] = $obj; $a->b(); class myclass { private $a = 1; private $b = 2; public function __sleep() { return array('a'); } } ...

Serialiazing various types into one file

Hi. I'm using a BinaryFormatter to serialize my object. I have various object types in their relevant lists. Is there a 'best' way to serialize all the objects into one file, but be able to separate them on deserialization? At the moment, I'm deserializing the whole file and checking a specific field in each object to see what list I s...