<?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>All About KnownTypes</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx</link><description>&amp;lt;This turned out to be longer than what I had intended. Sorry about it&amp;gt; One of the common errors in Deserialization is “Element ' 'http://mycompany.com/:shape' ' contains data of the ' http://mycompany.com/:Circle ' data contract. The deserializer</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: All About KnownTypes</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#1069871</link><pubDate>Mon, 13 Nov 2006 20:51:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1069871</guid><dc:creator>SaravanaMV</dc:creator><description>&lt;p&gt;Hello Sowmy,&lt;/p&gt;
&lt;p&gt;1. Used XsdObjectGen to create my typed classes from an XSD file. &lt;/p&gt;
&lt;p&gt;2. Created a WCF Service with one OperationContract which returns one of the typed methods generated earlier.&lt;/p&gt;
&lt;p&gt;[OperationContract]&lt;/p&gt;
&lt;p&gt;SupplierCatalogue GetSupplierCatalogue(string ccountNumber)&lt;/p&gt;
&lt;p&gt;3. Hosted within IIS&lt;/p&gt;
&lt;p&gt;4. Generated client code within VS by &amp;quot;Add Service Reference&amp;quot;&lt;/p&gt;
&lt;p&gt;5. When I try to call the web method. I'm getting the following error (tracing is enabled)&lt;/p&gt;
&lt;p&gt;&amp;lt;Message&amp;gt;There was an error while trying to serialize parameter &lt;a rel="nofollow" target="_new" href="http://tempuri.org/:GetSupplierCatalogueResult"&gt;http://tempuri.org/:GetSupplierCatalogueResult&lt;/a&gt;. The InnerException message was 'Type 'Fujitsu.Catalogue.Feed.ProductlineItem' with data contract name 'ProductlineItem:&lt;a rel="nofollow" target="_new" href="http://schemas.datacontract.org/2004/07/Fujitsu.Catalogue.Feed"&gt;http://schemas.datacontract.org/2004/07/Fujitsu.Catalogue.Feed&lt;/a&gt;' is not expected. 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 list of known types passed to DataContractSerializer.'. &amp;nbsp;Please see InnerException for more details.&amp;lt;/Message&amp;gt;&lt;/p&gt;
&lt;p&gt;Inside my typed class, definition of ProductlineItem looks like &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;[XmlType(TypeName = &amp;quot;ProductlineItem&amp;quot;, Namespace = Declarations.SchemaVersion), Serializable]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public class ProductlineItem&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;Schema roughly looks like&lt;/p&gt;
&lt;p&gt;SupplierCatalogue&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;|---CatalogueHeader&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;|------(Some header specif elements)&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;|---CatalogueDetail&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;|------ProductlineItem (0 to *)&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;|----------(Some product line item specific elements)&lt;/p&gt;
&lt;p&gt;Any quick thought, how I can fix it. Generating typed classes using xsd.exe didn't help (even though it worked) because when we serialize the class the element names are different on the client side.&lt;/p&gt;
&lt;p&gt;I can send you the schema and generated file.....my email addr saravana(dot)kumar(at)digitaldeposit(dot)co(dot)uk&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Saravana&lt;/p&gt;
</description></item><item><title>re: All About KnownTypes</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#2484900</link><pubDate>Tue, 08 May 2007 22:09:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2484900</guid><dc:creator>Rama.NET</dc:creator><description>&lt;p&gt;Hi Sowmy&lt;/p&gt;
&lt;p&gt;Thanks for sharing this with us. It is working while retrieve a collection of objects, which has cyclic references.&lt;/p&gt;
&lt;p&gt;I implemented your solution and knocked down fetching issues I had before.&lt;/p&gt;
&lt;p&gt;Now I am getting into trouble, while sending back the modified collection. If I modify only the parent and set the child to null, it is great. If modify the child and parent or if I modify the child then I am getting into IndexOutOfrange issue. Apparently I increased maxarraylength and maxItemsinObjectGraph, and started getting a different error message, Object graph for type BusinessEntity contains cycles and cannot be serialized if reference tracking is disabled. And the stack trace is showing me some inner classes of System.Runtime.Serialization.XmlObjectSerializerWriteContext.OnHandleReference(XmlWriterDelegator xmlWriter, Object obj, Boolean canContainCyclicReference) and so on. Could you please help me out in this?&lt;/p&gt;
</description></item><item><title>electroholic &amp;raquo; WCF - Extending DataContract types in closed packages</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#3992409</link><pubDate>Sat, 21 Jul 2007 23:43:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3992409</guid><dc:creator>electroholic » WCF - Extending DataContract types in closed packages</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://electroholic.com/?p=5"&gt;http://electroholic.com/?p=5&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>While True  &amp;raquo; Blog Archive   &amp;raquo; WCF KnownType / KnownTypeAttribute</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#4032463</link><pubDate>Tue, 24 Jul 2007 22:14:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4032463</guid><dc:creator>While True  » Blog Archive   » WCF KnownType / KnownTypeAttribute</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://whiletrue.nl/blog/?p=36"&gt;http://whiletrue.nl/blog/?p=36&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>windows mobile free themes download</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#5664148</link><pubDate>Thu, 25 Oct 2007 13:17:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5664148</guid><dc:creator>windows mobile free themes download</dc:creator><description>&lt;p&gt;windows mobile free themes download&lt;/p&gt;
</description></item><item><title>DataContract Serialization, Entity Framework and "Known Types"</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#6756603</link><pubDate>Thu, 13 Dec 2007 10:30:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6756603</guid><dc:creator>system.data.objects dev guy</dc:creator><description>&lt;p&gt;One of the challenges encountered when using DataContract serialization (the default for WCF web services)&lt;/p&gt;
</description></item><item><title>DataContract Serialization, Entity Framework and "Known Types"</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#6756664</link><pubDate>Thu, 13 Dec 2007 10:39:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6756664</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;One of the challenges encountered when using DataContract serialization (the default for WCF web services&lt;/p&gt;
</description></item><item><title>MSDN Blog Postings  &amp;raquo; DataContract Serialization, Entity Framework and "Known Types"</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#6758248</link><pubDate>Thu, 13 Dec 2007 13:01:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6758248</guid><dc:creator>MSDN Blog Postings  » DataContract Serialization, Entity Framework and "Known Types"</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://msdnrss.thecoderblogs.com/2007/12/13/datacontract-serialization-entity-framework-and-known-types/"&gt;http://msdnrss.thecoderblogs.com/2007/12/13/datacontract-serialization-entity-framework-and-known-types/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>KnownType error</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#8593155</link><pubDate>Thu, 12 Jun 2008 16:55:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8593155</guid><dc:creator>Atteint de JavaScriptite Aiguë [Cyril Durand]</dc:creator><description>&lt;p&gt;Lorsque vous cr&amp;#233;ez un service WCF, vous allez cr&amp;#233;er un contrat. Dans la plupart des cas, ce contrat est&lt;/p&gt;
</description></item><item><title>WCF : KnownType - Comment retourner des types enfants du type définit dans le ServiceContract</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#8593160</link><pubDate>Thu, 12 Jun 2008 16:58:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8593160</guid><dc:creator>Atteint de JavaScriptite Aiguë [Cyril Durand]</dc:creator><description>&lt;p&gt;Lorsque vous cr&amp;#233;ez un service WCF, vous allez cr&amp;#233;er un contrat. Dans la plupart des cas, ce contrat est&lt;/p&gt;
</description></item><item><title>re: All About KnownTypes</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#8832732</link><pubDate>Tue, 05 Aug 2008 05:32:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8832732</guid><dc:creator>leolite1</dc:creator><description>&lt;p&gt;Hi Sowmy,&lt;/p&gt;
&lt;p&gt;The article was quite informational but I did not understand the knownTypes definition under system.runtime.serialization. I tried including a declaration under system.runtime.serialization for a simple WCF service in a website for but it doesn't seem to be respected.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
</description></item><item><title>re: All About KnownTypes</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#9581361</link><pubDate>Fri, 01 May 2009 00:48:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9581361</guid><dc:creator>jy.boudreau</dc:creator><description>&lt;p&gt;Hi Sowny,&lt;/p&gt;
&lt;p&gt;Great article, thanks for sharing. One comment:&lt;/p&gt;
&lt;p&gt;You mention this as a common case for using KnownTypes:&lt;/p&gt;
&lt;p&gt;&amp;quot;2- When passing a DataContract class instance as an item in ISerializable class such as System.Exception. This is due to the fact that ISerializable is an untyped (System.Object based) bag.&amp;quot;&lt;/p&gt;
&lt;p&gt;Which I totally agree is a common case, but I have to add that having ISerializable class being marshaled that is not an Exception is a very valid case. Later when you mention:&lt;/p&gt;
&lt;p&gt;&amp;quot;Scenario #2 will never arise if the user follows the fault contract guidance and explicitly declare fault types as FaultContract and not use exception for faults. In general it is recommended to avoid ISerializable in a contract oriented application.&amp;quot;&lt;/p&gt;
&lt;p&gt;Here is where I disagree. What if the you don't control the type you want to serialize? What if this type is part of some 3rd-party library. Then using the KnownTypes with generic parameters is crucial if that 3rd-party class embeds even a generic collection.&lt;/p&gt;
&lt;p&gt;In my case, the 3rd-party class was a class from the Microsoft Synchronization framework, which sadly uses ISerializable instead of DataContract.&lt;/p&gt;
</description></item><item><title>re: All About KnownTypes</title><link>http://blogs.msdn.com/sowmy/archive/2006/06/06/all-about-knowntypes.aspx#9865800</link><pubDate>Wed, 12 Aug 2009 10:51:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9865800</guid><dc:creator>sunit_82</dc:creator><description>&lt;p&gt;Hi sowmy,&lt;/p&gt;
&lt;p&gt;Excellent article. &lt;/p&gt;
&lt;p&gt;There is one question have though.&lt;/p&gt;
&lt;p&gt;What if the service method(Operation contract) takes a argument of type 'object' and from client we pass it any other 'user defined' type.&lt;/p&gt;
&lt;p&gt;In this case how can we manage using either KnownType attribute or config file?&lt;/p&gt;
&lt;p&gt;Thanx&lt;/p&gt;
&lt;p&gt;s.a.w&lt;/p&gt;
</description></item></channel></rss>