简体   繁体   中英

ASP.NET MVC 5 Ninject: Ninject.MVC3/5

I want to add Ninject to an ASP.NET MVC 5 Project.

NinjectWebCommon.cs is not in the App_Start folder. In a tutorial I read that Ninject.MVC3 should be added via Nuget.

If I go into 'Manag NuGet Packages' and search for 'Ninject' I get the following:

NuGet搜索:Ninject

There I find 'Ninject.MVC5'. A symbol indicates that this package is installed.

But when I go to 'Installed packages' I see the following:

已安装的NuGet Ninject软件包

Here I cannot find this package.

Why is the package not listed here?

Should I install 'Ninject.MVC3' although 'Ninject.MVC5' seems to be installed?


Edit:


I have now installed the NuGet Package via the Package Manager Console like the following:

Each package is licensed to you by its owner. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.

Package Manager Console Host Version 2.8.50926.663

Type 'get-help NuGet' to see all available NuGet commands.

PM> Install-Package Ninject.MVC5
Attempting to resolve dependency 'Ninject (≥ 3.2.0.0 && < 3.3.0.0)'.
Attempting to resolve dependency 'Ninject.Web.Common.WebHost (≥ 3.0.0.0)'.
Attempting to resolve dependency 'Ninject.Web.Common (≥ 3.2.0.0 && < 3.3.0.0)'.
Attempting to resolve dependency 'WebActivatorEx (≥ 2.0 && < 3.0)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.
'Ninject.MVC5 3.2.1.0' already installed.
Adding 'WebActivatorEx 2.0' to WebApplication.
Successfully added 'WebActivatorEx 2.0' to WebApplication.
Adding 'Ninject.Web.Common.WebHost 3.2.0.0' to WebApplication.
Successfully added 'Ninject.Web.Common.WebHost 3.2.0.0' to WebApplication.
Adding 'Ninject.MVC5 3.2.1.0' to WebApplication.
Successfully added 'Ninject.MVC5 3.2.1.0' to WebApplication.

It says that Ninject.MVC5 is already installed but adds the necessary files to the ASP.NET MVC Project anyways.

Now the Package also is under Installes Packages:

在此处输入图片说明

This way I can go on and use Ninject in my project. Though, I still do not really understand what happened here. Why where the files not in my ASP.NET MVC project? Why did Visual Studio state that the package was installed, but why was it not under installed packages? Is there a reason for this or is this a software bug?

转到package.config并使用'ninject'删除行。之后,通过Package Manager控制台从NuGet Package重新安装ninject。

Try Install-Package Ninject.MVC5 or Ninject.MVC3. For my case its MVC5.

安装软件包Ninject-版本3.0.1.10安装软件包Ninject.Web.Comon-版本3.0.0.7安装软件包Ninject.MV3-版本3.0.0.6

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM