I'm building a C# class in Visual Studio 2015 CTP 6, within an ASP.NET Web Application project (it's MVC). The class needs to read RSS feeds, and according to this StackOverflow post, the best way to do this is via the System.ServiceModel.Syndication
namespace.
I tried adding the DLL needed for this by right-clicking References
under the web.app
folder in Visual Studio's Solution Explorer. Then I selected Add Reference... In the dialog box, it didn't have any ASP.NET 5.0 libraries listed; it only had the 4.0 version of various libraries listed. So I added System.ServiceModel
(4.0.0.0).
Now Visual Studio is 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 RssFeedModels.cs
class:
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 do I resolve this issue? Thank you.
Update: Modified the project.json
file as recommended by heymega
. Here's what the project.json
file's pertinent 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 throws many 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