Vivendi
Vivendi

Reputation: 21017

Reference Microsoft.AspNet.Mvc package from Class library

I have a class library project created with Visual Studio 2015. I tried to add the package Microsoft.AspNet.Mvc to my project with NuGet. That worked out fine a you can see from the screenshot.

enter image description here

But whenever I try to use the Microsoft.AspNet.Mvc namespace in my project, it complains that it cannot find the given namespace.

The type or namespace name AspNet does not exist in the namespace 'Microsoft'

But it's clearly referenced in my project... Anyone any idea what the problem is?

Upvotes: 0

Views: 788

Answers (2)

Amir Fahmideh
Amir Fahmideh

Reputation: 465

I have just add the code below to my project.json file and rebuild the project and the problem solved,now I have access to using Microsoft.AspNet.Mvc;

 "frameworks": {
"dnx451": { },
"dnxcore50": { }}

Upvotes: 1

Eilon
Eilon

Reputation: 25704

Change your class library to be a project.json (i.e. MyClassLib.xproj) and then reference Microsoft.AspNet.Mvc 6.0.0-*.

I'm not sure a csproj class library project can consume MVC 6.

Upvotes: 0

Related Questions