<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PointCollection not serializable with NetDataContractSerializer in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/pointcollection-not-serializable-with/m-p/150695#M3785</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Geometry objects are DataContracts and can be serialized with the regular DataContractSerializer, but if you try to use the System.Runtime.Serialization.NetDataContractSerializer it will fail because it requires the PointCollection type to be marked as a data contract (which it is not).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
// Create a geometry
Polyline polyline = new Polyline();
PointCollection points = new PointCollection();
points.Add(new MapPoint(0, 0));
points.Add(new MapPoint(1, 1));
polyline.Paths.Add(points);

// Serialize it
NetDataContractSerializer serializer = new NetDataContractSerializer();
using (System.IO.MemoryStream stm = new System.IO.MemoryStream())
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; serializer.Serialize(stm, polyline);
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Produces this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.Runtime.Serialization.InvalidDataContractException occurred. Message=Type 'ESRI.ArcGIS.Client.Geometry.PointCollection' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.&amp;nbsp; If the type is a collection, consider marking it with the CollectionDataContractAttribute.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be great to have full support for this in the final version. Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;--Ryan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Mar 2010 15:21:39 GMT</pubDate>
    <dc:creator>RyanCooney</dc:creator>
    <dc:date>2010-03-31T15:21:39Z</dc:date>
    <item>
      <title>PointCollection not serializable with NetDataContractSerializer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/pointcollection-not-serializable-with/m-p/150695#M3785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Geometry objects are DataContracts and can be serialized with the regular DataContractSerializer, but if you try to use the System.Runtime.Serialization.NetDataContractSerializer it will fail because it requires the PointCollection type to be marked as a data contract (which it is not).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
// Create a geometry
Polyline polyline = new Polyline();
PointCollection points = new PointCollection();
points.Add(new MapPoint(0, 0));
points.Add(new MapPoint(1, 1));
polyline.Paths.Add(points);

// Serialize it
NetDataContractSerializer serializer = new NetDataContractSerializer();
using (System.IO.MemoryStream stm = new System.IO.MemoryStream())
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; serializer.Serialize(stm, polyline);
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Produces this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;System.Runtime.Serialization.InvalidDataContractException occurred. Message=Type 'ESRI.ArcGIS.Client.Geometry.PointCollection' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.&amp;nbsp; If the type is a collection, consider marking it with the CollectionDataContractAttribute.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be great to have full support for this in the final version. Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;--Ryan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Mar 2010 15:21:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/pointcollection-not-serializable-with/m-p/150695#M3785</guid>
      <dc:creator>RyanCooney</dc:creator>
      <dc:date>2010-03-31T15:21:39Z</dc:date>
    </item>
  </channel>
</rss>

