ASP.NET MVC 5 Ninject:Ninject.MVC3/5 [英] ASP.NET MVC 5 Ninject: Ninject.MVC3/5

查看:115
本文介绍了ASP.NET MVC 5 Ninject:Ninject.MVC3/5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Ninject添加到ASP.NET MVC 5项目中.

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

NinjectWebCommon.cs不在App_Start文件夹中. 在一个教程中,我读到应该通过Nuget添加Ninject.MVC3.

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

如果我进入"Manag NuGet软件包"并搜索"Ninject",则会得到以下信息:

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

我在那里找到"Ninject.MVC5".符号表示已安装此软件包.

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

但是当我转到已安装的软件包"时,会看到以下内容:

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

在这里我找不到此软件包.

Here I cannot find this package.

为什么软件包未在此处列出?

Why is the package not listed here?

尽管似乎已经安装了"Ninject.MVC5",但我应该安装"Ninject.MVC3"吗?

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

我现在已经通过程序包管理器控制台安装了NuGet程序包,如下所示:

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.

它说已经安装了Ninject.MVC5,但是无论如何都将必要的文件添加到ASP.NET MVC项目中.

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:

这样,我就可以继续在项目中使用Ninject了.虽然,我仍然不太明白这里发生了什么.为什么文件不在我的ASP.NET MVC项目中?为什么Visual Studio声明已安装该软件包,但为什么不在已安装的软件包中?是有原因还是这是软件错误?

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?

推荐答案

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

Install-Package Ninject -version 3.0.1.10 Install-Package Ninject.Web.Comon -version 3.0.0.7 Install-Package Ninject.MV3 -version 3.0.0.6

这篇关于ASP.NET MVC 5 Ninject:Ninject.MVC3/5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆