<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx</link><description>Dictionaries have been an annoyance when serializing for a while now. IDictionary in v1.1 and now IDictionary&amp;lt;K,V&amp;gt; in v2.0 are both non-serializable, forcing us to find workarounds or use DataTables or any number of unsatisfactory solutions. My</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#7237340</link><pubDate>Fri, 23 Oct 2009 17:58:09 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7237340</guid><dc:creator>Wray</dc:creator><author>Wray</author><description>&lt;p&gt;I think there might be some updates here for .NET 3.5. I am having no problem with a serialized Dictionary&amp;lt;int, List&amp;lt;int&amp;gt;&amp;gt; that I am using in WCF. I think the difference might be a different serializer. When using a DataContract, the NetDataContractSerializer is being used by default. Let's put it this way. I got the values on the server, passed them back through WCF and I got what I started with no problem. The class is not marked Serializable, it is marked DataContract and compiliation does not complain either.&lt;/p&gt;
&lt;p&gt;So this is probably not an issue with WCF if you don't need to mark a class Serializable as well. This may work with a BinaryFormatter for serialization as well.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7237340" width="1" height="1"&gt;</description></item><item><title>re: Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#6790407</link><pubDate>Tue, 16 Dec 2008 13:31:06 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6790407</guid><dc:creator>sandy</dc:creator><author>sandy</author><description>&lt;p&gt;Thanks, works really welll :)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6790407" width="1" height="1"&gt;</description></item><item><title>re: Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#6725143</link><pubDate>Fri, 07 Nov 2008 11:03:36 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6725143</guid><dc:creator>Martin</dc:creator><author>Martin</author><description>&lt;p&gt;Ignore previous comment, anything derived from IDictionary apparently cannot be (de)serialized.&lt;/p&gt;
&lt;p&gt;Another idea for refactoring though: the serializable key value pair struct could be implemented without generic parameters because the encapsulating class already specifies them, thus the struct could simply be non-generic like this:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public struct SerializableKeyValuePair&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public K Key;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public V Value;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public SerializableKeyValuePair(KeyValuePair&amp;lt;K, V&amp;gt; kvp)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.Key = kvp.Key;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.Value = kvp.Value;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6725143" width="1" height="1"&gt;</description></item><item><title>re: Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#6725093</link><pubDate>Fri, 07 Nov 2008 09:41:24 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6725093</guid><dc:creator>Martin</dc:creator><author>Martin</author><description>&lt;p&gt;Why are you trying to (de)serialize IDictionary&amp;lt;K,V&amp;gt; when .NET has a perfectly serializable class Dictionary&amp;lt;K,V&amp;gt;??&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6725093" width="1" height="1"&gt;</description></item><item><title>¿Goodbye Dictionary?</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#6405769</link><pubDate>Wed, 16 Jul 2008 08:01:54 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6405769</guid><dc:creator>400 Bad Request</dc:creator><author>400 Bad Request</author><description>&lt;p&gt;Correcci&amp;#243;n al art&amp;#237;culo (16/07/2008): Todas las mediciones de tiempo efectuadas en las compartivas entre&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6405769" width="1" height="1"&gt;</description></item><item><title>¿Goodbye Dictionary?</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#6405768</link><pubDate>Wed, 16 Jul 2008 08:01:52 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6405768</guid><dc:creator>El blog de Lluis Franco</dc:creator><author>El blog de Lluis Franco</author><description>&lt;p&gt;Correcci&amp;#243;n al art&amp;#237;culo (16/07/2008): Todas las mediciones de tiempo efectuadas en las compartivas entre&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6405768" width="1" height="1"&gt;</description></item><item><title>re: Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#6405306</link><pubDate>Wed, 16 Jul 2008 05:39:08 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6405306</guid><dc:creator>Markus</dc:creator><author>Markus</author><description>&lt;p&gt;Thanks! Very useful...&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6405306" width="1" height="1"&gt;</description></item><item><title>¿Goodbye Dictionary?</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#6401099</link><pubDate>Tue, 15 Jul 2008 08:07:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6401099</guid><dc:creator>El blog de Lluís Franco en Geeks.ms</dc:creator><author>El blog de Lluís Franco en Geeks.ms</author><description>&lt;p&gt;Generics La aparici&amp;#243;n del framework 2.0 nos trajo una grata sorpresa: La aparici&amp;#243;n de Generics, que nos&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6401099" width="1" height="1"&gt;</description></item><item><title>re: Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#2629223</link><pubDate>Mon, 21 May 2007 15:06:20 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:2629223</guid><dc:creator>Faxedhead</dc:creator><author>Faxedhead</author><description>&lt;p&gt;Thanks mate - appreciate this. &amp;nbsp;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=2629223" width="1" height="1"&gt;</description></item><item><title>re: Serializing Dictionaries</title><link>http://weblogs.asp.net/avnerk/archive/2006/05/23/Serilalizing-Dictionaries.aspx#463198</link><pubDate>Thu, 03 Aug 2006 15:07:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:463198</guid><dc:creator>Chris McKelt</dc:creator><author>Chris McKelt</author><description>&lt;p&gt;Works like a charm thanks!!!&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=463198" width="1" height="1"&gt;</description></item></channel></rss>