<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx</link><description>This post has been updated to account for the changes to the DataContractResolver in the Beta 2 release of .NET 4.0. 
 
 This will be my first of several posts about new features that are showing up in the Beta 1 release of .NET 4.0. Beta 1 was released</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#10294749</link><pubDate>Wed, 18 Apr 2012 00:11:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10294749</guid><dc:creator>Youssef Moussaoui - MSFT</dc:creator><description>&lt;p&gt;@Vivin and Abhaye, yes in general you&amp;#39;ll need compatible resolvers on the client side and the server side. Without DataContractResolver on the client side, you&amp;#39;ll need to use the default contract name, namespace for that type, but you won&amp;#39;t be able to deserialize just any type&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10294749" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#10283129</link><pubDate>Wed, 14 Mar 2012 19:13:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10283129</guid><dc:creator>Abhaye</dc:creator><description>&lt;p&gt;Hi, I seem to be facing an issue with deserializing the dynamic object in silverlight. I am using the generic resolver with my wcf service to resolve the dynamic known types and sending the entity object on a call back channel using duplex service. I get the message at the client end but the entity object is null. &lt;/p&gt;
&lt;p&gt;Seems like the resolver works for the service end, but there is nothing at the silverlight end to resolve the type of object in the incoming message. how can I overcome this deserializing issue.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10283129" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#10266841</link><pubDate>Sat, 11 Feb 2012 12:34:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10266841</guid><dc:creator>Vivin Joy</dc:creator><description>&lt;p&gt;Do we need to bind this DataContractResolver on both client and host side explicitly, Or does binding on host side is sufficient?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10266841" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#10182046</link><pubDate>Thu, 30 Jun 2011 18:27:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10182046</guid><dc:creator>Youssef Moussaoui - MSFT</dc:creator><description>&lt;p&gt;Unfortunately, this feature hasn&amp;#39;t quite made it to silverlight yet, but you should expect to see it in a future version of silverlight.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10182046" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#10171125</link><pubDate>Fri, 03 Jun 2011 14:26:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10171125</guid><dc:creator>Nick</dc:creator><description>&lt;p&gt;Any tips on getting the client side in silverlight using this - it looks like a different method may need to be employed through attributes? &amp;nbsp;Any Samples for that?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10171125" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#10168604</link><pubDate>Thu, 26 May 2011 10:46:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10168604</guid><dc:creator>Great, except...</dc:creator><description>&lt;p&gt;This works great for me, except for certain types, e.g. sometimes I get the error: &amp;quot;Enum value &amp;#39;0&amp;#39; is invalid for type &amp;#39;System.Security.Permissions.SecurityAction&amp;#39; and cannot be serialized. Ensure that the necessary enum values are &amp;nbsp;present and are marked with with EnumMemberAttribute if the type has DataContractAttribute attribute.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10168604" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#9935008</link><pubDate>Thu, 10 Dec 2009 08:07:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9935008</guid><dc:creator>Jan-Erik Romøren</dc:creator><description>&lt;p&gt;Ok, thanks for the answer. So, in the first place we wanted to get rid of ServiceKnownType, which we were hoping to do by using DataContractResolver. The reason for using ServiceKnownType in the first place was because we return interfaces. So, the conclusion seem to be that this cannot be done, since the DataContractResolver won't work with interfaces.&lt;/p&gt;
&lt;p&gt;On the other hand, we now managed to get the serialization/deserialization from Entity Framework to work. We had to make a resolver, and also use ServiceKnownType (which was missing).&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9935008" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#9932856</link><pubDate>Sat, 05 Dec 2009 00:58:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9932856</guid><dc:creator>Youssef Moussaoui - MSFT</dc:creator><description>&lt;p&gt;As far as DataContractSerializer is concerned, interfaces are just like the type 'object'. Serialization only cares about fields and properties, not methods. And interfaces can only define methods. (Quick note: the one exception to this rule are the special-cased IEnumerable, ICollection, IList, and IDictionary which are treated as collections)&lt;/p&gt;
&lt;p&gt;So known types will always be used if your return type is an interface. Now, you should still be able to use a DataContractResolver to map the type back and forth on the wire.&lt;/p&gt;
&lt;p&gt;If you're in need of changing the namespace of the contract on the wire, you could create a &amp;quot;fake&amp;quot; data contract to return instead of your interface, and then use a resolver that resolves any types that implement that interface. You don't need to have your classes derive from the new &amp;quot;fake&amp;quot; contract; everything should just work.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932856" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#9932504</link><pubDate>Fri, 04 Dec 2009 14:02:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9932504</guid><dc:creator>Jan-Erik Romøren</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thanks for the good article. One question though; I've implemented a DataContractResolver, and it works great. One problem though, my services returns interfaces. Since I'm not able to set the DataContract attribute on the interfaces, I'm not able to specify a namespace. And because of this, the deserialization fails.&lt;/p&gt;
&lt;p&gt;We have been using the KnownType attribute, but it doesn't do the trick when we're now starting to use Entity Framework 4.0 with POCO. This is where the DataContractResolver seem to do the job, but it's a pitty we can't find a way to return interfaces...&lt;/p&gt;
&lt;p&gt;So, do you have any idea how to do this?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9932504" width="1" height="1"&gt;</description></item><item><title>re: Configuring Known Types Dynamically - Introducing the DataContractResolver</title><link>http://blogs.msdn.com/b/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx#9930318</link><pubDate>Mon, 30 Nov 2009 19:12:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9930318</guid><dc:creator>Youssef Moussaoui - MSFT</dc:creator><description>&lt;p&gt;You can't set a DataContractResolver out-of-the-box through configuration, but you should be able to create a custom ServiceHost that sets your own resolver for use in IIS. Here's a sample: &lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/aa395224.aspx"&gt;http://msdn.microsoft.com/en-us/library/aa395224.aspx&lt;/a&gt;.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9930318" width="1" height="1"&gt;</description></item></channel></rss>