I am following the MVC tutorial, I installed PagedList package, and I cannot use the PagedList reference in the controller.
The type or namespace name 'PagedList' could not be found (are you missing a using directive or an assembly reference?).
First sorry for my terrible English. In my case, I use the MVC5 in Visual Studio Community 2015 and I solved the problem this way:
First I delete the cache of Visual Studio and NuGet cache:
Visual studio - go to %LocalAppData% \Microsoft\WebsiteCache and delete all folder.
Nuget - here
After I use the package manager console to remove PagedList.MVC, then remove PagedList and then re-install them again like so:
uninstall-package PagedList.mvc
uninstall-package PagedList
install-package PagedList
install-package PagedList.mvc
I holpe that help
Include
using PagedList;
using PagedList.Mvc;
in the pgm and run
PagedList and PagedList.Mvc are being installed separately.
NuGet console install commands:
Install-Package PagedList
Install-Package PagedList.Mvc
Make sure you've installed both of packages.
Check your references to see if there is a reference to the PagedList assembly.
If there isn't: Try to reinstall the package
If there is a reference: Check if the file actually exists on the location specified.
Reference example http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-29-92/7750.v20SysRefProps.JPG
I use DNN. My problem was the package (DotNetNuke.Core.8.0.1.239) was outdated.
Check in your solution folder if you have the package installed:
..MySolutionFolder\packages\DotNetNuke.Core.8.0.1.239 (your package name)
Right click on Solution, go to Manage Nuget Packages.
Click on Browse, search for DotnetNuke.
Install:
DotNetNuke.Core
DotNetNuke.Web
I had the issue was because I was using another more than one web application and they did not use the same framework version :)
Related
I am trying to make Newtonsoft.json available for use in my local Visual Studio 2010 projects. I installed NuGet.Tools on my system. Now I see an item in the Solution Explorer called Service References that wasn't there before, but I don't understand how to use that to reference the Newtonsoft package I also downloaded, which is currently in my Downloads folder. Do I need to move the package to a different location to reference it?
Thanks for your help.
You can right click on the project where you want to install newtonsoft nuget package.
You will find an option "Manage NuGet packages".
Then search online for "newtonsoft".
This would add a packages.config file in your project (depending on which framework you are targeting to ).
this new file contains all the nuget dependencies required for this project.
Refer this blog for more details
VS2010 is old and is unable to update to the latest NuGet version. This means that adding recent packages will often fail; however, you can often add an older version of a package that has a compatible NuGet version and it will work. This causes the suggested answer by #ManojChoudhari to fail for me. In the case of Newtonsoft.Json, the following worked using the Package Manager Console:
Install-Package Newtonsoft.Json -Version 9.0.1
I have an ASP NET MVC 4 project that "works on my machine(old)". When I load a project in a fresh installation of VS 2015(on a new laptop) - a lot of assemblies are missing and when I try to build the project it complains that classes like ActionResult, Controller are missing.
I checked that on the old laptop the missing dependencies are coming from C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies. On the new laptop I have only the xml descriptors of the packages but not the dlls.
What I have to install to use MVC 4 in Visual Studio 2015?
Edit: missing dependencies are:
System.Web.Helpers
System.Web.Mvc
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
I Recommend getting them again from Nuget for your ActionResult Issue its Microsoft.AspNet.Mvc which is making issue.
Open Package Manager Console and insert the command below:
Install-Package Microsoft.AspNet.Mvc
Nuget has this feature that allows you to restore all the missing Assemblies which exists in nuget. you can try that out as well.
Anyway for the rest of them install these packages below as well:
Install-Package Microsoft.AspNet.WebHelpers
Install-Package Microsoft.AspNet.WebPages
Install-Package Microsoft.AspNet.Razor
Check if you have install update 3 for VS2015
also check if Microsoft web developer tools are installed correctly
I have had the same issues when using source control or moving projects from one PC to another.
There is a work around that I use quite often and it works.
Go to YourProjectFolder -> packages.
Remove all the folders except for the xml, repositories.xml, file which is the xml config file for packages downloaded from Nuget.
On your solution in Visual Studio Right click and select Enable Nuget Packages Restore.
Then build the application it will re-download all the required packages.
Hope this helps
For Me what solved the issue is to install ASP.NET MVC 4 for Visual Studio 2010 from Microsoft Web Page
I have a MVC3 application in Visual Studio 2010 . I need to refer the scripts/styles in layout page using following tag
#System.Web.Optimization.Styles.Render("~/Content/css")
#System.Web.Optimization.Scripts.Render("~/Scripts/script")
But I am unable to use like this, since System.web,optimization is not available from _Layout.cshtml( even though the dll is referred in the project).Please refer to below image
how to resolve this?
First install Microsoft.AspNet.Web.Optimization using Package Manager Console using below command.
Install-Package Microsoft.AspNet.Web.Optimization
Next you need to reference the dll System.Web.Optimization.dll in your web project then you can add this namespace #using System.Web.Optimization in your_Layout.cshtml`.
Also make sure System.Web.Optimization.dll is present in bin folder in project.
Install-Package Microsoft.AspNet.Web.Optimization
In the Nuget Package Manager Console.
I am trying to install Entity Framework for MVC application.But I am getting following error:
Install-Package : Unable to find version '5.0.0.0' of package 'entityframework'
I was struck with the same issue and the below steps resolved the problem
Right click on the Project which throws the Nuget error
Select Manage NuGet Packages..
Click on Settings button in the bottom left corner
Under Available package sources,Select the checkbox nuget.org
Click on OK.
Now the packages will be automatically downloaded from the site.
Try installing the package by right-clicking on the project in visual studio -> 'Manage NuGet Packages' and search for EntityFramework.
Entity framework 5 is uploaded without the latest 0 on the version.
This should work
Install-Package EntityFramework -Version 5.0.0
For other versions look here
http://www.nuget.org/packages/EntityFramework/
It Worked .I went to http://www.nuget.org/packages/EntityFramework and then installed NuGet using Visual Studio Extension Manager and then in the console window I gave command Install-Package EntityFramework -Version 5.0.0 and it worked out.
I faced same issue. When i checked my proxy and made sure that internet connection is fine and has a reach over NuGet links, restarting VS later solved my problem.
I am following this article on RazorGenerator and it say's that I must add references to:
System.Web.Helpers.dll
System.Web.WebPages.dll
System.Web.Razor.dll
The only one I can see when I do Add Reference is System.Web.Razor, but I don't know where the other ones are.
You will find these assemblies in the Extensions group under Assemblies in Visual Studio 2010, 2012 & 2013 (Reference Manager)
To sum up all of the options for VS 2017, WebHelpers was installed by installing MVC in previous versions of Visual Studio. If you're getting this error, you probably don't have the older versions of VS installed anymore.
So, installing the Microsoft.AspNet.MVC NuGet package will require Microsoft.AspNet.WebPages and Microsoft.AspNet.Razor, and the Microsoft.AspNet.WebPages includes System.Web.Helpers.dll.
If you've got direct references to System.Web.Mvc.dll and you don't want to use NuGet for MVC, you can get the Microsoft.AspNet.WebPages NuGet, or there are some other NuGet packages that only contain System.Web.Helpers.dll, like the microsoft-web-helpers or System-Web-Helpers.dllpackages.
There appear to be 2 versions of System.Web.Helpers.dll, one for .Net 4.0 and one for 4.5. Choosing the correct version of MVC or AspNet.WebPages will ensure you get the right one.
As for VS2017 I didn't find it in "extensions", there's a Nuget package called "microsoft-web-helpers" that seems to be equivalent to System.Web.Helpers.
I had the same problem , first I couldn't find those dlls in the list of .NET components . but later I figured it out that the solution is :
1- first I changed target framework from .NET framework 4 client profile to .NET framework 4.
2- then scroll down the list of .NET components , pass first list of system.web... , scroll down , and find the second list of system.web... at the bottom , they're there .
I hope this could help others
In VS 2010 just right click on project or on reference and click add reference.
On the popup window Select Assemblies - > Extensions -> System.Web.Helpers
Installing ASP.NET MVC3 from here should help.
On VS2017 I installed the NuGet package: Microsoft.AspNet.WebPages
That did the trick.
This particular NuGet package has a habit of losing its references in one of our projects. From time to time I will need to run the following command in the Package Manager Console to restore the references and everything is OK again
Update-Package Microsoft.AspNet.Webpages -reinstall
I had to install RazorGenerator.Templating to get it all to work. From the NuGet console, type:
Install-Package RazorGenerator.Templating
They should be under C:\Program Files\Microsoft ASP.Net (or C:\Program Files (x86)\Microsoft ASP.Net if you're on a 64-bit OS) in a subfolder for MVC3 or WebPages.
The issue is a missing or outdated version of MVC. I was running VS 2015Preview and could resolve the issue by installing the latest version of MVC via NuGet.
Just in case anyone is still coming across this one.
When you install this nuget package Microsoft.AspNet.WebPages they can be find in C:\Program Files (x86)\Microsoft Visual Studio\Shared\Packages\Microsoft.AspNet.WebPages.x.x.x\lib\net45