安装 Ninject.MVC5 后出现 FileLoadException [英] FileLoadException after installing Ninject.MVC5

查看:31
本文介绍了安装 Ninject.MVC5 后出现 FileLoadException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 Adam Freeman 的Pro ASP.NET MVC 5"一书学习 ASP.NET MVC.不幸的是,所有使用 Ninject 的项目都会抛出相同的错误

I am trying to learn ASP.NET MVC with Adam Freeman's "Pro ASP.NET MVC 5" book. Unfortunately all projects using Ninject throw the same error

Ninject.dll 中发生了System.IO.FileLoadException"类型的异常,但未>在用户代码中处理

An exception of type 'System.IO.FileLoadException' occurred in Ninject.dll but was not >handled in user code

附加信息:无法加载文件或程序集System.Web.Mvc,>Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"或其依赖项之一.定位的程序集的清单定义与程序集 > 引用不匹配.(来自 HRESULT 的异常:0x80131040)

Additional information: Could not load file or assembly 'System.Web.Mvc, >Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its >dependencies. The located assembly's manifest definition does not match the assembly >reference. (Exception from HRESULT: 0x80131040)

这与本线程中讨论的问题完全相同,

This is exactly the same problem which was discussed in this thread,

在 mvc 5 中安装 ninject mvc 3 后的问题项目

但提供的解决方案对我不起作用.

but the offered solutions don't work for me.

我尝试过目标平台 4.5 和 4.5.1、Ninject MVC3 和 MVC5.我也插入了这个片段

I have tried target platforms 4.5 and 4.5.1, Ninject MVC3 and MVC5. I have also inserted this snippet

<runtime>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
  </dependentAssembly>
</runtime>

Web.config文件中,没有任何影响.

in the Web.config file, without any effect.

问题必须在 Ninject MVC3 和 MVC5 包中.每当安装这些包时,对 Ninject.StandardKernel() 的任何调用都会引发异常,无论是从 Global.asax 还是新的 NinjectWebCommon.cs 或任何其他代码段(当然,无论如何,这对于这种异常应该无关紧要,但在此线程中 将 Ninject 与 ASP.NET V4 一起使用时出错 建议该错误可能与使用 Global.asax 连接 Ninject 有关到应用程序).

Problem must be in the Ninject MVC3 and MVC5 packages. Whenever these packages are installed, any call to Ninject.StandardKernel() throws the exception, regardless if made from the Global.asaxor the new NinjectWebCommon.cs or from any other piece of code (of course, this should not matter for this kind of exception anyway, but in this thread Error using Ninject with ASP.NET V4 it was suggested that the error might have something to do with using the Global.asax for connecting Ninject to the application).

我的想法已经用完了.有人可以帮忙吗?

I have run out of ideas. Can anyone help?

推荐答案

添加到您的 Web.config(即 SportsStore.WebUI 项目):

Add to your Web.config (i.e. SportsStore.WebUI project):

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

它应该适用于这个 -> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

It should work with this -> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

这篇关于安装 Ninject.MVC5 后出现 FileLoadException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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