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

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

问题描述

我想学习ASP.NET MVC与亚当·弗里曼的临ASP.NET MVC 5的书。不幸的是使用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

型System.IO.FileLoadException的异常出现在Ninject.dll但没有>用户code处理

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

信息:无法加载文件或程序'System.Web.Mvc,>版本= 3.0.0.0,文化=中性公钥= 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,

<一个href=\"http://stackoverflow.com/questions/23374406/issues-after-installing-ninject-mvc-3-in-mvc-5-project\">Issues在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 或其它任何一块code(当然,这不应该的问题对于这种异常无论如何,但在此线程有人建议,错误使用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>

应该有这方面的工作 - > &LT; assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1&GT;

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

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