Error Using Ninject in MVC 5 - c#

I do the following steps:
Open VS Express 2013 for Web
Create Empty MVC 5 Project
Select Tools ➤ Library Package Manager ➤ Manage Nuget Package for Solutions
Install Ninject.MVC5.
When I run debug I saw this:
I am so confuse with this error since I am new to MVC and Ninject. I already use assembly redirect because It's seem it use System.Web.Mvc version 3.0.0.0, but it's still error.
Anyone can help me?

Uninstall ninject from your project and install it again:
Select Tools-> Library Package Manager-> Package Manager Console in Visual Studio to
open the NuGet command line and enter the following commands:
Install-Package Ninject
Install-Package Ninject.Web.Common
Install-Package Ninject.MVC5
If the error continues checks that the version of System.Web.Mvc is 5.0 not another.

First, Unistall the ninject you have Install with this code
Uninstall-Package Ninject.MVC5.
Note: you put a dot(.) at the end of MVC5, i think that gave you the error.
Now, you can Install the package again with these following code
Install-Package Ninject.MVC5
resource: https://www.nuget.org/packages/Ninject.MVC5/

Related

I can`t install Package "Microsoft.VisualStudio.Web.CodeGeneration.Design" In VisualStudio 2019 Comunity Version 16.6.2

I want to install "Microsoft.VisualStudio.Web.CodeGeneration.Design" Package to Create AreaMVC and make views but The VisualStudio has this error
enter image description here
Given the error Visual Studio gave you, it seems that you cannot connect to the nuget servers.
Do you have a proxy enabled, or a firewall that is blocked nuget?
Can you access nuget and download any other packages?
If so, can you access the url in the error in a regular browser?
Have you tried installing it through the Package Manager Console? (Using the command Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 3.1.3)

NuGet Package default package removed

I created a new website in VS2015, then I removed some of the NuGet packages.
This caused the project (website) build to fail. I created a new project (website) again. That build was also to fail.
For example I get the error:
Error BC30002 Type 'BundleCollection' is not defined.
Project not defined app_code folder and .cs files and did not run.
And I created a new project (ASP.NET MVC or Web Form). This also failed to build.
I use Update-Package -reinstall, Not again
It's better to update your Visual Studio , because older versions have outdated templates with old package references.
But you can update these templates manulally too. First try to run the following command:
PM> Update-Package
It will update all of your decencies at once.
Or you can just install the latest package which contains the BundleCollection:
PM> Install-Package Microsoft.AspNet.Web.Optimization
And then update your MVC dependencies:
PM> update-package Microsoft.AspNet.Mvc
PM> update-package Microsoft.Web.Infrastructure
After that, search for all of the web.config files in your solution (there should be at least 2 of them) and then correct the old assembly versions in them. It's very important. Otherwise you will be able to compile your project but you won't be able to run it.

How to install ASP.NET 5 IIS Loader using nuget

I am trying to run a new asp.net5 project on IIS loader, but I can't get it to work.
The error message is:
Could not find the Microsoft.AspNet.Loader.IIS.Interop Nuget Package in your users packages folder.This NuGet package is required to run ASP.NET 5 web applications.
I have installed the NuGet Package Manager for Visual Studio 2015 (as you can see in the image here) and have installed the Microsoft.AspNet.Loader.IIS 1.0.0-beta7 (prerelease) nuget package (screenshot).
What am I missing?
Asp.Net 5 is no longer supported and replaced by Asp.Net Core now. I recommend you to migrate your project to Asp.Net Core and then try again. You can follow this link to migrate your project: Migrating from ASP.NET 5 RC1 to ASP.NET Core 1.0.
According to the error message, the missing package is Microsoft.AspNet.Loader.IIS.Interop. But in your second screenshot, you are installing Microsoft.AspNet.Loader.IIS package, which is not the missing package.
Please install the Microsoft.AspNet.Loader.IIS.Interop package with command "Install-Package Microsoft.AspNet.Loader.IIS.Interop -Pre" in Package Manager Console.
In addition, please make sure your Visual Studio has enabled auto restore nuget packages through Tools -> Options -> NuGet Package Manager -> General.

Managing References in Visual Studio 2012

Please help me understand: I have a Visual Studio project. It has Nuget package manager enabled. I install several libraries. The library versions are shown in packages.config. Each library has a corresponding entry in References.
Now, say I want to change the library version from, say, 2.2.0 to 2.1.0. How I do this? At first I assumed you could just change the version number in packages.config. But when I do this, and get Nuget to download an earlier version of the library, the project references are not changed.
Do I have to manually remove each and every reference in the project to 2.2.0 and replace it with 2.1.0?
I get the feeling I'm "doing it wrong", but there doesn't seem to be any examples I can find of anyone doing it right.
Thanks for any help!
Using jQuery as an example:
If you want to rollback to a previous version you can run the Uninstall-Package jQuery and Install-Package jQuery -Version 2.1.0 commands from the package manager console.
Also, the package nuget page will have a list off all the versions available. EX: jQuery
All of this and more available in the nuget Docs
You can't simply change the version in the config file since your project still holds a reference to the binaries, so the binaries need to be replaced too.
Now, I'm not entirely sure if there is a "downgrade" Powershell command but you can certainly uninstall the specific package and then install a lower version. By using the Package Manager Console. So from within Visual Studio:
Go to the View menu -> Other Windows -> Package Manager Console
Select the Default Project from the dropdown list
Then run the following command to uninstall the package
The command to uninstall is...
Uninstall-Package YOUR_PACKAGE_NAME
To install a lower version, run this command...
Install-Package YOUR_PACKAGE_NAME -Version 1.0
These and other commands are very well documented in The Package Manager Console Powershell Reference
Uninstall-Package Command
Install-Package Command

How to add Unity.WebAPI to a .net 4.0 project

I am trying to add Unity.WebAPI to a .net 4.0 project. The latest version, 5.1.0 is for .Net 4.5 so I am trying to use version 0.10.0. I've tried using the Nuget Package Manager Console to install this version using the command:
Install-Package Unity.WebAPI -Version 0.10.0
It installs successfully but the reference in my project is notated with the caution symbol as if there is a problem. When I try to build I get the following error message:
The referenced component 'Unity.WebAPI' could not be found
Unity.WebApi is dependent on Unity which I have successfully installed version 2.1.505.0
One thing I have noticed is that when I go into my packages\Unity2.1.505.0\lib folder, I only have a NET35 and SL30 folder. I would think I would see a NET40 folder but that might be insignificant.
One other note is that I did try installing the later version of Unity.WebAPI version 5.1 which is dependent on Unity 3.0.1304.1 which is not compatible with .net 4.0.
I would welcome any ideas or suggestions on getting Unity.WebAPI installed on my .Net4.0 project. I'd also be glad to provide anymore information one might need to help.
Thanks in advance.

Categories