Select to view content in your preferred language

System.Runtime.Serialization  Version????

4365
10
04-09-2010 12:44 PM
AngelGonzalez
Frequent Contributor
I was able to get a simple ArcGIS silverlight app up and running. I then tried to use the sample identify that ESRI posted as part of their SL sample site.  I am using ArcGIS Silverlight SDK 1.2 along with SL3 and SDK3. The error applies when ever I post the following in my code:

<esriSymbols:PictureMarkerSymbol x:Name="DefaultPictureSymbol" OffsetX="35" OffsetY="35"
                     Source="/Images/i_about.png" />


Error:
The "ValidateXaml" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'


The version of 'System.Runtime.Serialization' that SL3 installed is 3.0.50106

What am I mising? Are the samples out of dates? SL4 installed version 4.0...

Thanks
0 Kudos
10 Replies
dotMorten_esri
Esri Notable Contributor
Simply add a reference to System.Runtime.Serialization
0 Kudos
AngelGonzalez
Frequent Contributor
It worked.  Thanks!
0 Kudos
WilliamDonahue
Emerging Contributor
Hey guys... i know it has been a while since this post was created but i am having the same issue. where is the dll hidden so that i may reference it.
0 Kudos
AngelGonzalez
Frequent Contributor
Just add a reference to your project (right click, then Add Reference) and then select the System.Runtime.Serialization.
0 Kudos
TonyHuynh
Emerging Contributor
Hello,
I ran into the same issue (working on the GeoRSS sample http://help.arcgis.com/EN/webapi/silverlight/samples/start.htm#GeoRSS).
After adding the system.runtime.serilization reference, it solved that error. However, I also received other errors:

Error 6 The name 'SyndicationFeed' does not exist in the current context C:\Student\CEWA\M4\M4\MainPage.xaml.cs 69 28 M4
Error 8 The name 'XDocument' does not exist in the current context C:\Student\CEWA\M4\M4\MainPage.xaml.cs 119 29 M4
Error 2 The type or namespace name 'Linq' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?) C:\Student\CEWA\M4\M4\MainPage.xaml.cs 11 18 M4
Error 1 The type or namespace name 'Syndication' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?) C:\Student\CEWA\M4\M4\MainPage.xaml.cs 6 27 M4
Error 3 The type or namespace name 'SyndicationFeed' could not be found (are you missing a using directive or an assembly reference?) C:\Student\CEWA\M4\M4\MainPage.xaml.cs 61 17 M4
Error 4 The type or namespace name 'SyndicationItem' could not be found (are you missing a using directive or an assembly reference?) C:\Student\CEWA\M4\M4\MainPage.xaml.cs 62 22 M4
Error 5 The type or namespace name 'SyndicationItem' could not be found (are you missing a using directive or an assembly reference?) C:\Student\CEWA\M4\M4\MainPage.xaml.cs 62 60 M4
Error 7 The type or namespace name 'XDocument' could not be found (are you missing a using directive or an assembly reference?) C:\Student\CEWA\M4\M4\MainPage.xaml.cs 119 13 M4
Error 9 The type or namespace name 'XNamespace' could not be found (are you missing a using directive or an assembly reference?) C:\Student\CEWA\M4\M4\MainPage.xaml.cs 120 13 M4

Note: I am trying to use the sample code from - http://help.arcgis.com/EN/webapi/silverlight/samples/start.htm#GeoRSS

Here are 2 screenshots attached:

Any guidance or words of wisdom on how to proceed to get this sample to work will be greatly appreciated! My final project, which involves incorporate GeoRSS Feed(s) is due in less than 48 hours 😞

Thank You!!
0 Kudos
RichardWatson
Deactivated User
Just Goggle the class it cannot resolve then chose the MSDN link.  On the MSDN page, chose  the Silverlight version and it will give you everthing you need:

http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed(v=VS.95).asp...
0 Kudos
TonyHuynh
Emerging Contributor
Thank you so much!! It's working now. I had to add a few references (i.e. system.ServiceModel.Syndication)

Edit:

I was able to publish the map onto my server, and everything looks fantastic! Except for one item: I can't get the feed for some reason....

When I tried to fetch a feed within my published map, nothing happens or I receive the error message. On the other hand, when I used the same feed (http://earthquake.usgs.gov/eqcenter/catalogs/eqs7day-M2.5.xml)  or a different feed within the sample map (http://help.arcgis.com/EN/webapi/silverlight/samples/start.htm#GeoRSS), it was able to fetch the feed.

I'm not sure what's wrong with my code? I was able to debug and publish my map.

Here's my code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using System.Xml;
using System.Xml.Linq;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;


namespace M4
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Fetch_Click(object sender, RoutedEventArgs e)
        {
            if (FeedLocationTextBox.Text != String.Empty)
            {
                LoadRSS(FeedLocationTextBox.Text.Trim());
                DispatcherTimer UpdateTimer = new System.Windows.Threading.DispatcherTimer();
                UpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, 60000);
                UpdateTimer.Tick += (evtsender, args) =>
                {
                    LoadRSS(FeedLocationTextBox.Text.Trim());
                };
                UpdateTimer.Start();
            }
        }

        protected void LoadRSS(string uri)
        {
            WebClient wc = new WebClient();
            wc.OpenReadCompleted += wc_OpenReadCompleted;
            Uri feedUri = new Uri(uri, UriKind.Absolute);
            wc.OpenReadAsync(feedUri);
        }

        private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {

            if (e.Error != null)
            {
                FeedLocationTextBox.Text = "Error in Reading Feed. Try Again later!!";
                return;
            }

            // Optional, use LINQ to query GeoRSS feed.
            //UseLinq(e.Result); return;

            using (Stream s = e.Result)
            {
                SyndicationFeed feed;
                List<SyndicationItem> feedItems = new List<SyndicationItem>();

                GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.ClearGraphics();

                using (XmlReader reader = XmlReader.Create(s))
                {
                    feed = SyndicationFeed.Load(reader);
                    foreach (SyndicationItem feedItem in feed.Items)
                    {
                        SyndicationElementExtensionCollection ec = feedItem.ElementExtensions;

                        string x = "";
                        string y = "";
                        string magnitude = feedItem.Title.Text;

                        foreach (SyndicationElementExtension ee in ec)
                        {
                            XmlReader xr = ee.GetReader();
                            switch (ee.OuterName)
                            {
                                case ("lat"):
                                    {
                                        y = xr.ReadElementContentAsString();
                                        break;
                                    }
                                case ("long"):
                                    {
                                        x = xr.ReadElementContentAsString();
                                        break;
                                    }
                            }
                        }

                        if (!string.IsNullOrEmpty(x))
                        {
                            Graphic graphic = new Graphic()
                            {
        Geometry = new MapPoint(Convert.ToDouble(x, System.Globalization.CultureInfo.InvariantCulture),
              Convert.ToDouble(y, System.Globalization.CultureInfo.InvariantCulture)),
                                Symbol = LayoutRoot.Resources["QuakePictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
                            };

                            graphic.Attributes.Add("MAGNITUDE", magnitude);

                            graphicsLayer.Graphics.Add(graphic);
                        }
                    }
                }
            }
        }

        private void UseLinq(Stream s)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            XDocument doc = XDocument.Load(s);
            XNamespace geo = "http://www.w3.org/2003/01/geo/wgs84_pos#";

            var rssGraphics = from rssgraphic in doc.Descendants("item")
                              select new RssGraphic
                              {
                                  Geometry = new MapPoint(
           Convert.ToDouble(rssgraphic.Element(geo + "long").Value, System.Globalization.CultureInfo.InvariantCulture),
           Convert.ToDouble(rssgraphic.Element(geo + "lat").Value, System.Globalization.CultureInfo.InvariantCulture)),
                                  Symbol = LayoutRoot.Resources["QuakePictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                                  RssAttributes = new Dictionary<string, object>() { { "MAGNITUDE", rssgraphic.Element("title").Value } }
                              };

            foreach (RssGraphic rssGraphic in rssGraphics)
            {
                foreach (KeyValuePair<string, object> rssAttribute in rssGraphic.RssAttributes)
                {
                    rssGraphic.Attributes.Add(rssAttribute.Key, rssAttribute.Value);
                }               
                graphicsLayer.Graphics.Add((Graphic)rssGraphic);
            }
        }

        internal class RssGraphic : Graphic
        {
            public Dictionary<string, object> RssAttributes { get; set; }
        }
    }
}
0 Kudos
TonyHuynh
Emerging Contributor
Here's a screen shot

*Almost got this to work*   Crossing my fingers...

Thank you so much!! It's working now. I had to add a few references (i.e. system.ServiceModel.Syndication)

Edit:

I was able to publish the map onto my server, and everything looks fantastic! Except for one item: I can't get the feed for some reason....

When I tried to fetch a feed within my published map, nothing happens or I receive the error message. On the other hand, when I used the same feed (http://earthquake.usgs.gov/eqcenter/catalogs/eqs7day-M2.5.xml)  or a different feed within the sample map (http://help.arcgis.com/EN/webapi/silverlight/samples/start.htm#GeoRSS), it was able to fetch the feed.

I'm not sure what's wrong with my code? I was able to debug and publish my map.

Here's my code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
using System.Xml;
using System.Xml.Linq;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;


namespace M4
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Fetch_Click(object sender, RoutedEventArgs e)
        {
            if (FeedLocationTextBox.Text != String.Empty)
            {
                LoadRSS(FeedLocationTextBox.Text.Trim());
                DispatcherTimer UpdateTimer = new System.Windows.Threading.DispatcherTimer();
                UpdateTimer.Interval = new TimeSpan(0, 0, 0, 0, 60000);
                UpdateTimer.Tick += (evtsender, args) =>
                {
                    LoadRSS(FeedLocationTextBox.Text.Trim());
                };
                UpdateTimer.Start();
            }
        }

        protected void LoadRSS(string uri)
        {
            WebClient wc = new WebClient();
            wc.OpenReadCompleted += wc_OpenReadCompleted;
            Uri feedUri = new Uri(uri, UriKind.Absolute);
            wc.OpenReadAsync(feedUri);
        }

        private void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {

            if (e.Error != null)
            {
                FeedLocationTextBox.Text = "Error in Reading Feed. Try Again later!!";
                return;
            }

            // Optional, use LINQ to query GeoRSS feed.
            //UseLinq(e.Result); return;

            using (Stream s = e.Result)
            {
                SyndicationFeed feed;
                List<SyndicationItem> feedItems = new List<SyndicationItem>();

                GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
                graphicsLayer.ClearGraphics();

                using (XmlReader reader = XmlReader.Create(s))
                {
                    feed = SyndicationFeed.Load(reader);
                    foreach (SyndicationItem feedItem in feed.Items)
                    {
                        SyndicationElementExtensionCollection ec = feedItem.ElementExtensions;

                        string x = "";
                        string y = "";
                        string magnitude = feedItem.Title.Text;

                        foreach (SyndicationElementExtension ee in ec)
                        {
                            XmlReader xr = ee.GetReader();
                            switch (ee.OuterName)
                            {
                                case ("lat"):
                                    {
                                        y = xr.ReadElementContentAsString();
                                        break;
                                    }
                                case ("long"):
                                    {
                                        x = xr.ReadElementContentAsString();
                                        break;
                                    }
                            }
                        }

                        if (!string.IsNullOrEmpty(x))
                        {
                            Graphic graphic = new Graphic()
                            {
        Geometry = new MapPoint(Convert.ToDouble(x, System.Globalization.CultureInfo.InvariantCulture),
              Convert.ToDouble(y, System.Globalization.CultureInfo.InvariantCulture)),
                                Symbol = LayoutRoot.Resources["QuakePictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
                            };

                            graphic.Attributes.Add("MAGNITUDE", magnitude);

                            graphicsLayer.Graphics.Add(graphic);
                        }
                    }
                }
            }
        }

        private void UseLinq(Stream s)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            XDocument doc = XDocument.Load(s);
            XNamespace geo = "http://www.w3.org/2003/01/geo/wgs84_pos#";

            var rssGraphics = from rssgraphic in doc.Descendants("item")
                              select new RssGraphic
                              {
                                  Geometry = new MapPoint(
           Convert.ToDouble(rssgraphic.Element(geo + "long").Value, System.Globalization.CultureInfo.InvariantCulture),
           Convert.ToDouble(rssgraphic.Element(geo + "lat").Value, System.Globalization.CultureInfo.InvariantCulture)),
                                  Symbol = LayoutRoot.Resources["QuakePictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                                  RssAttributes = new Dictionary<string, object>() { { "MAGNITUDE", rssgraphic.Element("title").Value } }
                              };

            foreach (RssGraphic rssGraphic in rssGraphics)
            {
                foreach (KeyValuePair<string, object> rssAttribute in rssGraphic.RssAttributes)
                {
                    rssGraphic.Attributes.Add(rssAttribute.Key, rssAttribute.Value);
                }               
                graphicsLayer.Graphics.Add((Graphic)rssGraphic);
            }
        }

        internal class RssGraphic : Graphic
        {
            public Dictionary<string, object> RssAttributes { get; set; }
        }
    }
}
0 Kudos
RichardWatson
Deactivated User
I am guessing that this might relate to client access policy:

http://help.arcgis.com/en/webapi/silverlight/help/index.html#//016600000009000000.htm
0 Kudos