简体   繁体   English

“SyndicationFeed”不包含“Load”的定义

[英]'SyndicationFeed' does not contain a definition for 'Load'

I'm trying to read rss feeds using Syndicationfeed class.我正在尝试使用 Syndicationfeed 类读取 rss 提要。 I have added a reference to System.servicemodel.syndication.我添加了对 System.servicemodel.syndication 的引用。

this is my error Project.SyndicationFeed' does not contain a definition for 'Load'这是我的错误 Project.SyndicationFeed' 不包含 '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;

        }
      }

   }
}

The problem was that somehow a class SyndicationFeed.cs got added to my project which caused conflicts when calling the .Load() method.问题是不知何故 SyndicationFeed.cs 类被添加到我的项目中,这在调用 .Load() 方法时导致了冲突。

After deleting this file from the class everything went fine.从班级中删除此文件后,一切正常。

Thanks to @user2864740 for pointing this out and leading me to the solution.感谢@user2864740 指出这一点并引导我找到解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM