serialization

Cannot serialize member … of type System.Collections.Generic.Dictionary`2 because it implements IDictionary

白昼怎懂夜的黑 提交于 2019-12-24 01:03:30
问题 I am trying to pass a class with a Dictionary property over WCF and it is failing for one method but works for another. When the class is returned inside a List , it works. But when the class is returned inside a DataTable , the client just says the connection was disconnected and no error shows up. Here is the class causing issues: [DataContract] public class DetailLog { [DataMember] public string Name { get; set; } [DataMember] public string SubAction { get; set; } [DataMember] public

Protobuf-net skip deserialization of specific fields

蹲街弑〆低调 提交于 2019-12-24 00:57:33
问题 I have serialized this class: [ProtoContract] public class TestClass { [ProtoMember(1)] public int[] hugeArray; [ProtoMember(2)] public int x; [ProtoMember(3)] public int y; //lot more fields and properties to serialize here... } How do I skip the [ProtoMember(1)] hugeArray during deserialization, so that only x, y, and other fields get deserialized? My problem is that sometimes I quickly need only to get the 'metadata', which is what other fields and properties describe, but sometimes I need

Undesrtanding Java Serialization

房东的猫 提交于 2019-12-24 00:47:35
问题 I'm trying to compare the standard Java desiralisation. And have a question if it's a correct way to do this. I wrote the following class: //{"first", 1234.1234, 21341234, 234123412341234124L, "fifth"} public class ArrayInputStreamStub extends InputStream{ public int[] arr = new int[260]; private int reader = 0; public ArrayInputStreamStub(){ reader[0] = -84; //... } @Override public int read() throws IOException { return arr[reader++]; } public void reset() { reader = 0; } } I have the same

Limiting unserialize() to return arrays?

此生再无相见时 提交于 2019-12-24 00:47:30
问题 Is there any way to limit PHP's unserialize() to only parse arrays? For security reasons. Suppose there is is an evil __unserialize() magic method in the unserialized object I don't wanna call! 回答1: There are a couple of ways you could solve this problem: Use a regex on the serialized string: Piwik patched an unserialize vulnerability with the following check: if (preg_match('/^a:[0-9]+:{/', $str) && !preg_match('/(^|;|{|})O:\+?[0-9]+:"/', $str) Sign the signed string. If you add an sha1 Hash

How to use deserialized object?

那年仲夏 提交于 2019-12-24 00:44:47
问题 I am serializing and deserializing an Object in C# for Windows 8 Apps. I am serializing my Object before passing it to the next View, because passing an object throws out exceptions. function OnNavigatedTo: protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); string XMLString = e.Parameter.ToString(); var thisChannel = XmlDeserializeFromString(XMLString, typeof(Channel)); ....} Deserializing Function: public static Channel XmlDeserializeFromString<Channel>

(don't ?) use JavaScriptSerializer to convert xml file (of unknown schema) to json in c#

混江龙づ霸主 提交于 2019-12-24 00:44:13
问题 Is JavascriptSerializer the "tool" to convert an xml file (of unknown schema) into a json string ? There are some threads here dealing about how to convert xml to json in c#. And some recommended dedicated solutions (http://www.phdcc.com/xml2json.htm) But in those threads there are always one suggesting using JavaScriptSerializer. But there is never clear explanation on how to do it. One always elude it or start with an object instead of an xml. To make it clear : I don't look after having my

WCF serialization and Value object pattern in Domain Driven Design

限于喜欢 提交于 2019-12-24 00:41:43
问题 The book Domain Driven Design by Eric Evans describes pattern called value object. One of the important characteristics of a value object is that it is immutable. As an example I have a value object "Clinic" which must have a name and an id. To make it a value object I do not provide setters on name and id. Also to make sure that there is not invalid instance I take name and id in a constructor and do not provide at parameter less constructor. public class Clinic { public Clinic(string name,

Ansible: Can't set variable for sequential execution

走远了吗. 提交于 2019-12-24 00:37:58
问题 I'm trying to build a playbook with rolling update use case (Sequential Execution) with the serial element. Since I have to use the serial value in multiple places in the playbook, I wanted to use it as a variable which can be used to define somewhere as a group variable. Inventory file [all] webserver1 ansible_host=10.1.1.1 ansible_user=root webserver2 ansible_host=10.1.1.2 ansible_user=root webserver3 ansible_host=10.1.1.3 ansible_user=root dbserver1 ansible_host=10.1.2.1 ansible_user=root

Sending Byte[] (TreeView) over TCP C#

扶醉桌前 提交于 2019-12-24 00:35:29
问题 this may sound abit complex but i have a TreeView on a computer. I then convert it to a byte array, send it through TCP, convert the byte array back into a tree view and then view it again. For some reason its very buggy, the exact same treeview might work one time, then not for the next 10 times. It seems to work alot more if the TreeView is smaller. I know for a fact the error is from sending it through tcp because ive made a program which just converts it to byte array and back which works

How to de-serialize an entity, put it in managed context, but not persist any changes?

余生颓废 提交于 2019-12-24 00:35:10
问题 I'm new to persistence and I want to do the following: 1) Load a part of database into entities and store them in a file 2) Load these entities from file, put them in managed context (so that all the @JoinColumn and @JoinTable, especially those with lazy fetch type, would work normally) and make sure that I don't accidentally update database with them. The point of all that is that every time I start the application I don't want to call database for the table that almost never change - so I