asp.net – 无法加载文件或程序集“System.Web.Mvc,Version = 3.0.0.0,Elmah.MVC问题

前端之家收集整理的这篇文章主要介绍了asp.net – 无法加载文件或程序集“System.Web.Mvc,Version = 3.0.0.0,Elmah.MVC问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
本地 – 我的MVC 4,asp.net,c#应用程序运行良好在IIS 8 / Windows 8。

当部署到Windows Server 2008时,我收到此错误

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)

[FileLoadException: Could not load file or assembly 'System.Web.Mvc,PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   Elmah.Mvc.Bootstrap.Initialize() +0

[InvalidOperationException: The pre-application start initialization method Initialize on type Elmah.Mvc.Bootstrap threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc,PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodscore(ICollection`1 methods,Func`1 setHostingEnvironmentCultures) +12881963
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12881672
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +240
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException) +1151

[HttpException (0x80004005): The pre-application start initialization method Initialize on type Elmah.Mvc.Bootstrap threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc,PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881108
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context) +12722297

如果我从项目属性/包/发布web中的“要部署的项目”下拉列表中选择“只需要运行此应用程序的文件”,就会发生这种情况。

如果我选择“这个项目中的所有文件”,它工作正常。

我猜Elmah是依赖于一个旧版本的MVC或东西 – 我该如何解决这个问题,而不必上传所有的文件

什么是解决这种情况的最佳方式?

谢谢。

解决方法

我有这个完全相同的问题使用MVC4与Ninject为.Net 4.5

解决这个问题,我不得不添加一个绑定重定向到我的Web.config文件
(在文件末尾,紧靠< / configuration>标记之前)

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

这将强制Web服务器使用System.Web.Mvc 4.0.0.0而不是旧版本。

原文链接:https://www.f2er.com/aspnet/254256.html

猜你在找的asp.Net相关文章