加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 安装Ninject.MVC5后的FileLoadException

发布时间:2020-12-16 09:11:46 所属栏目:asp.Net 来源:网络整理
导读:我正在尝试使用Adam Freeman的“Pro ASP.NET MVC 5”一书来学习ASP.NET MVC.不幸的是,所有使用Ninject的项目都会抛出相同的错误 An exception of type ‘System.IO.FileLoadException’ occurred in Ninject.dll but was not handled in user code Additiona
我正在尝试使用Adam Freeman的“Pro ASP.NET MVC 5”一书来学习ASP.NET MVC.不幸的是,所有使用Ninject的项目都会抛出相同的错误

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

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)

这与此主题中讨论的问题完全相同,

Issues after installing ninject mvc 3 in mvc 5 project

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

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

<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文件中,没有任何影响.

问题必须在Ninject MVC3和MVC5包中.无论何时安装这些软件包,对Ninject.StandardKernel()的任何调用都会抛出异常,无论是从Global.asaxor中获取新的NinjectWebCommon.cs还是从任何其他代码片段(当然,这对于这种类型的无关紧要)异常无论如何,但在这个线程Error using Ninject with ASP.NET V4中,有人建议该错误可能与使用Global.asax将Ninject连接到应用程序有关.

我已经没想完了.有人可以帮忙吗?

解决方法

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

<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”>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读