首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装ASP.NET 5.0版本的System.ServiceModel.Syndication

安装ASP.NET 5.0版本的System.ServiceModel.Syndication
EN

Stack Overflow用户
提问于 2015-05-15 15:04:46
回答 1查看 5.2K关注 0票数 3

我正在VisualStudio2015CTP 6中构建一个C#类,它位于一个ASP.NET Web应用程序项目(它是MVC)中。类需要读取RSS,根据这个StackOverflow post,最好的方法是通过System.ServiceModel.Syndication命名空间。

通过右键单击Visual的解决方案资源管理器中的References文件夹下的web.app文件夹,我尝试添加了此操作所需的DLL。然后我选择了添加引用。在对话框中,它没有列出任何ASP.NET 5.0库;它只列出了各种库的4.0版本。因此我添加了System.ServiceModel (4.0.0.0)。

现在Visual正在抛出以下错误:

代码语言:javascript
复制
...\src\web.app\Models\RssFeedModels.cs(4,14): ASP.NET Core 5.0 error CS0234: The type or namespace name 'ServiceModel' does not exist in the namespace 'System' (are you missing an assembly reference?)
...\src\web.app\Models\RssFeedModels.cs(21,17): ASP.NET Core 5.0 error CS0246: The type or namespace name 'SyndicationFeed' could not be found (are you missing a using directive or an assembly reference?)
...\src\web.app\Models\RssFeedModels.cs(25,20): ASP.NET Core 5.0 error CS0103: The name 'SyndicationFeed' does not exist in the current context

这是我的RssFeedModels.cs课程:

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Xml;
using System.ServiceModel.Syndication;

namespace web.app.Models
{
    public class Rss
    {
        public string Title { get; set; }
        public string ContentSnippet { get; set; }
        public string Content { get; set; }
        public string PubDate { get; set; }
    }

    public class RssFeedModels
    {
        private XmlReader reader;
        private SyndicationFeed feed;

        public RssFeedModels(string url) {
            reader = XmlReader.Create(url);
            feed = SyndicationFeed.Load(reader);
        }
    }
}

我如何解决这个问题?谢谢。

更新:按照heymega的建议修改project.json文件。下面是project.json文件的相关部分的内容:

代码语言:javascript
复制
"commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
    "gen": "Microsoft.Framework.CodeGeneration",
    "ef": "EntityFramework.Commands",
    "run": "run"
},

"frameworks": {
    "dnx451": { },
    "dnxcore50": { },
    "aspnet50": {
        "dependencies": {
            "Microsoft.AspNet.Mvc": "6.0.0-beta2"
        },
        "frameworkAssemblies": {
            "System.ServiceModel": "4.0.0.0"
        }
    }
},

这会引发许多错误,从以下内容开始:

代码语言:javascript
复制
The type or namespace name 'ServiceModel' does not exist in the namespace 'System' (are you missing an assembly reference?) web.app.DNX 4.5.1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-15 15:30:17

System.ServiceModel尚未移植到ASP.NET 5,因此不能将其用作核心库的一部分。

您应该能够包含标准aspnet50项目(而不是核心)的引用。

代码语言:javascript
复制
{
    "commands": {
        "run": "run"
    },
    "frameworks": {
        "aspnet50": {
            "dependencies": {
                "Microsoft.AspNet.Mvc": "6.0.0-beta2"
            },
            "frameworkAssemblies": {
                "System.ServiceModel": "4.0.0.0"
            }
        }
    }
}

在尝试添加WCF服务引用时,我问了一个类似的问题here

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30262874

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档