<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codelab Blog &#187; WCF</title>
	<atom:link href="http://blog.codelab.co.nz/tag/wcf/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codelab.co.nz</link>
	<description>Technical Articles and News from Codelab Ltd</description>
	<lastBuildDate>Tue, 17 Jan 2012 13:10:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Serializing a Data Class (LINQ2SQL) for WCF</title>
		<link>http://blog.codelab.co.nz/2008/04/12/serializing-a-data-class-linq2sql-for-wcf/</link>
		<comments>http://blog.codelab.co.nz/2008/04/12/serializing-a-data-class-linq2sql-for-wcf/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 08:47:59 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[.NET Framework]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Linq]]></category>
		<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://blog.codelab.co.nz/?p=10</guid>
		<description><![CDATA[Problem I created a class that implements a service contract interface so that I can return an array of data from a WCF service back to the client application. The exposed method in the class return’s an array of Data Classes (an array of records from a database table) generated by the MSLINQ2SQL generator. When [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong></p>
<p>I created a class that implements a service  contract interface so that I can return an array of data from a WCF service back  to the client application.</p>
<p>The exposed method in the class return’s an  array of Data Classes (an array of records from a database table) generated by  the MSLINQ2SQL generator.</p>
<p>When generating the client code from the WCF  service, an exception was raised stating<br />
That the class could not be  serialized.</p>
<blockquote><p><em><span style="font-size: 85%;">S</span></em><span style="font-size: 85%;">ervice cannot be started.  System.Runtime.Serialization.InvalidDataContractException: Type  &#8216;TDC_LIB.OM.TMPPlan&#8217; cannot be serialized. Consider marking it with the  DataContractAttribute attribute, and marking all of its members you want  serialized with the DataMemberAttribute attribute.<br />
at  System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String  message, Type type)<br />
at  System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32  id, RuntimeTypeHandle typeHandle, Type type)<br />
at  System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32  id, RuntimeTypeHandle typeHandle, Type type)<br />
at  System.Runtime.Serialization.DataContract.GetDataContractSkipValidation(Int32  id, RuntimeTypeHandle typeHandle, Type type)<br />
at  System.Runtime.Serialization.DataContract.GetDataContract(RuntimeTypeHandle  typeHandle, Type type, SerializationMode mode)<br />
at  System.Runtime.Serialization.DataContract.GetDataContr&#8230;</span><em></em><strong></strong></p></blockquote>
<p><strong>Solution</strong><br />
Make  sure that your data context object has the property <strong>“Serialization  Mode”</strong> set to Unidirectional. This will add DataContract/DataMember  attributes to the associated fields in your data classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.codelab.co.nz/2008/04/12/serializing-a-data-class-linq2sql-for-wcf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

