Installing ASP.NET 5.0 System.ServiceModel.Syndication

I am creating a C # class in Visual Studio 2015 CTP 6 in an ASP.NET Web Application project (this is MVC). The class is supposed to read RSS feeds, and according to this StackOverflow question, the best way to do it is through the namespace System.ServiceModel.Syndication

.

I tried adding the required DLL for this by right clicking on References

the folder web.app

in Visual Studio Solution Explorer. Then I selected Add Reference ... In the dialog it did not have ASP.NET 5.0 libraries listed; it only had version 4.0 of various libraries. So I added System.ServiceModel

(4.0.0.0).

Visual Studio is now throwing these errors:

...\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

      

Here's my class RssFeedModels.cs

:

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);
        }
    }
}

      

How to solve this problem? Thank.

Refresh . The file was modified project.json

in accordance with the recommendations heymega

. This is what the corresponding project.json

file section looks like :

"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"
        }
    }
},

      

This causes a lot of errors, starting with this:

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

      

+3


source to share


1 answer


System.ServiceModel

hasn't been ported to ASP.NET 5

, but you can't use it as part of the core library.

You should be able to include a reference for a standard project aspnet50

(not core).



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

      

I asked a similar question here when trying to add a link to a WCF service.

+4


source







All Articles