Home > Cannot Serialize > Cannot Serialize Member Generic.dictionary

Cannot Serialize Member Generic.dictionary

share|improve this answer edited Jan 13 '10 at 13:02 answered Jan 13 '10 at 12:21 Edward Tanguay 63.5k236583887 While the DataContractSerializer is a good suggestion, it does not cover To exclude properties in your custom types, you need to mark them with attributes. Friday, August 04, 2006 7:02 PM Reply | Quote 1 Sign in to vote This question has come up a few times on internal discussion threads recently so I wanted to james_newtonking example: string json = @"{""key1"":""value1"",""key2"":""value2""}"; Dictionary values = JsonConvert.DeserializeObject>(json); Console.WriteLine(values.Count); // 2 Console.WriteLine(values["key1"]); // value1 share|improve this answer edited Dec 7 '11 at 11:41 Chandra Sekhar 9,36264275 answered check over here

Nice article. Usage Scenarios The main reason why I developed sharpSerializer was to save application configuration in an XML file. I think it is silly though that the dictionary data member is not serializable. XmlSerializer does not support dictionaries. http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member

needs an equality comparer which can’t be serialized into XML easily and won’t be portable anyhow. Reply MM says: September 18, 2015 at 6:38 am Simple, but very effective idea to serialize the class having Dictionary types! more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed

Go to top Permalink | Advertise | Privacy | Terms of Use | Mobile Web02 | 2.8.161101.1 | Last Updated 9 Nov 2011 Article Copyright 2010 by Pawel idzikowskiEverything else Copyright i think actually to use such a dictionary where key is the token, and the value is the type name in the new binary serializer. Browse other questions tagged c# wcf serialization datacontractserializer or ask your own question. Sign In·ViewThread·Permalink => 5 !

On 1941 Dec 7, could Japan have destroyed the Panama Canal instead of Pearl Harbor in a surprise attack? To tell the truth - never heard of them and never missed them yet... Reply Follow UsPopular TagsSCVMM AJAX PowerShell width MVVM dynamic width converter C# WPF databound WLC_VObject CreateRunspace runspacefactory Get-Template runspace CreatePipeline Percentage TR_SubtaskTrail Progess InvokePowerShell Archives February 2015(1) December 2014(1) April 2014(1) http://stackoverflow.com/questions/34316613/cannot-serialize-member-of-type-system-collections-generic-dictionary2-beca Bookmark the permalink. ← A REST Client Library for .NET, Part1 Why I’m In a Bad Mood Today (or, “Cowardly Credit CardCompanies”) → 7 Responses to One Way to SerializeDictionaries Oleg

http://www.dotmaniac.net Torsten Thank you. Moving forward, the recommended solution is to use System.Runtime.Serialization.DataContractSerializer. Is adding the ‘tbl’ prefix to table names really a problem? Sign In·ViewThread·Permalink InvalidCastException error but really SharpSerializer!!

Or is there some difference here that Im missing between an IDictionary and a Dictionary? This can significantly reduce the size of the serialized data. How do I handle this? Tuesday, June 27, 2006 5:51 PM Reply | Quote Moderator 0 Sign in to vote  mattdawg wrote:I am using XmlSerializer.  What other alternative should I use?You could try using SoapFormatter to

I got lost in the syntax after trying to do this. (I was trying to avoid converting .ToDictionary.) Thanks. check my blog Say you have User class (.Name, .Address, .Settings) that will be xml serialized. How to give Permission to create sandbox? I haven't put much attention to the updates, since I wouldn't expect the SharpSerializer is making such a rapid progress.

Most resources, websites, blogs etc say that it cannot be serialized. cheers Pawel modified on Tuesday, October 5, 2010 9:05 AM Sign In·ViewThread·Permalink Thanks! You got my five. http://sauvblog.com/cannot-serialize/cannot-serialize-member-of-type-system-collections-generic-ilist-1.html Sign In·ViewThread·Permalink Vote of 5, One Question, Though David Venegoni2-Jan-13 17:39 David Venegoni2-Jan-13 17:39 Great Article and Awesome Program.

For example: public abstract class A { public A(){} public abstract int Prop1 {get;} } public class B : A { private int prop1 = 1; public B(){} public override int I really needed something like this. sharpSerializer overcomes the above restrictions, and serializes objects with no need to mark your objects with additional attributes and without concerning types being serialized.

but this source belongs to the very first version of sharpserializer when all simple property values were strings.

it is possible that sharpSerializer does not see them also. All properties which are arrays (Type.IsArray==true), or which inherit from IEnumerable, ICollection or IDictionary are also serialized. Since SharpSerializer v.2.12 are all types serialized as AssemblyQualifiedName; i.e.: type="System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" You can alter the type naming by altering settings of sharpSerializer and setting the properties IncludeAssemblyVersionInTypeName, Sign In·ViewThread·Permalink Thanks kasiraj7-May-10 3:52 kasiraj7-May-10 3:52 Thanks tis code very usefully in my project Sign In·ViewThread·Permalink Incompatibility and other thoughts stolbovoy4-May-10 5:22 stolbovoy4-May-10 5:22 Sorry, for some critic,

Consider using a DataContractResolver or add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the It’s a different story on deserialization. Reply The man who knows says: August 24, 2012 at 7:08 am This is simple and brilliant. http://sauvblog.com/cannot-serialize/cannot-serialize-interface-system-collections-generic-ienumerable.html Maybe someone could explain to me why it can't be serialized.

boagrius8-Mar-12 15:55 boagrius8-Mar-12 15:55 Thank you for posting articles like this, it very helpful. I could have chosen to use the System.Collections.Generic.KeyValuePair type, but I wanted control over serialization, so I created my own simple KeyAndValue type. Please download the source code for more details. because it implements IDic...

You can however derive from a dictionary and add the functionality. In addtion you can see that I didn't want the default .net namespace in my xml so I setthe namespace of the xmlsericalizer to "". Are there comparative benchmarks available (speed of serialization and deserialization)? ExcludeFromSerializationAttribute is at the root of the sharpSerializer namespace and is easy to reach. [XmlIgnore] can be handled as well if someone needs it.

The declared property is of the type X, but it contains value of the type Y, where Y:X.