1

I'm trying to read rss feeds using Syndicationfeed class. I have added a reference to System.servicemodel.syndication.

this is my error Project.SyndicationFeed' does not contain a definition for 'Load'

Here's my code: (console application)

using System;
using System.Xml;
using System.ServiceModel.Syndication;

namespace ConsoleApplication2
{
   class Program
   {
      static void Main(string[] args)
      {
        string url = "http://fooblog.com/feed";
        XmlReader reader = XmlReader.Create(url);
        SyndicationFeed feed = new SyndicationFeed();
        feed = SyndicationFeed.Load(reader);
        reader.Close();
        foreach (SyndicationItem item in feed.Items)
        {
            String subject = item.Title.Text;    
            String summary = item.Summary.Text;

        }
      }

   }
}
user2864740
  • 60,010
  • 15
  • 145
  • 220
Giani Noyez
  • 481
  • 3
  • 8
  • 17
  • Okay, it says Static Member. What does it mean? – Giani Noyez Apr 01 '14 at 23:14
  • What .NET version do you use? – heq Apr 02 '14 at 01:44
  • @user2864740 I've changed it to `System.ServiceModel.Syndication.SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader);` and it seems to work but I don't have an idea why. I've seen answers on stackoverflow which did this: `SyndicationFeed feed = SyndicationFeed.Load(reader);` – Giani Noyez Apr 02 '14 at 08:47
  • @GianiNoyez Oh. Do you have your *own* class called `SyndicationFeed` by chance? – user2864740 Apr 02 '14 at 08:53
  • @user2864740 No I don't. Is that a necessary thing? – Giani Noyez Apr 02 '14 at 08:54
  • 1
    No, my initial hypothesis about the error was wrong. My new one is that there is another `SyndicationFeed` type somewhere and the issue goes away when you fully-qualify the typename. Try with `SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader);` (note that the full type is only specified once) and there will likely be an error about not being able to assign the types. If so, what's the *full* error? – user2864740 Apr 02 '14 at 08:56
  • @user2864740 `Cannot implicitly convert type 'System.ServiceModel.Syndication.SyndicationFeed' to 'ConsoleApplication2.SyndicationFeed'` This is the new error if I do it your way – Giani Noyez Apr 02 '14 at 11:31
  • 1
    @user2864740 After reading your comment several times I noticed you were right. I indeed had a SyndicationFeed.cs class. I didn't make it so I don't get why it was there. I removed it and now all my problems are gone. Thank you very much. – Giani Noyez Apr 02 '14 at 11:43
  • @GianiNoyez Cool, now on to the next problem! – user2864740 Apr 02 '14 at 19:06
  • @user2864740 Wish I could give you the answer mark – Giani Noyez Apr 02 '14 at 19:57
  • @GianiNoyez Just self-answer. Explain what was wrong, how it was discovered/fixed, and check the green arrow xD – user2864740 Apr 02 '14 at 20:07

1 Answers1

1

The problem was that somehow a class SyndicationFeed.cs got added to my project which caused conflicts when calling the .Load() method.

After deleting this file from the class everything went fine.

Thanks to @user2864740 for pointing this out and leading me to the solution.

Giani Noyez
  • 481
  • 3
  • 8
  • 17