2014-10-17 81 views
8

我昨天运行了Windows Update,并在我尝试释放ASP.NET MVC 4项目的新版本时引入了一些问题。窗口更新Brooke MVC应用程序

应用程序编译,当我推的版本为什么要在我的网络服务器测试站点它倒下,出现错误消息没关系但是本地运行,:

System.Web.HttpCompileException: (0): error CS1705: Assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 

经过一番研究,我发现,这是由于从4.0.0.0到4.0.0.1的更新。我从我的项目中删除了System.Web.Mvc dll,并且阅读了具有更高版本的dll。再次,一切工作在本地,但不在网上。然后我浏览了web.config,并将4.0.0.0中的任何内容更改为4.0.0.1。同样,这继续在内部工作,但在外部失败。该错误信息是:

  
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) 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileLoadException: 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) 

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded. 

WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. 

我相信这事做与我使用了错误处理ELMAH。

我试图从Nuget重新安装,如下面的建议:Windows update caused MVC3 and MVC4 stop working但这并没有奏效,我得到了同样的错误。

添加信息: 服务器尚未更新,我担心更新此可能会破坏现有的实时版本。

+0

[ASP.NET MVC安全修补程序版本3.0.0.1打破构建]的可能重复(http://stackoverflow.com/questions/26406877/asp-net-mvc-security-patch-to-version-3- 0-0-1-break-build) – 2014-10-17 13:08:02

回答

9

错误消息告诉我,您在其中一个配置文件中为MVC程序集指定了不正确的版本号。找到配置文件,使用不正确的版本,并将其更改为与您使用的任何版本(您在上面提到的4.0.0.1)相匹配。你需要检查所有的配置文件,包括

  • 的一个项目根
  • 的一个在浏览文件夹

你也可以做一个assembly redirect在你的配置文件取同样关心这一点 - 如果由于第三方库存而失败,这可能是最合适的行动。

根据您的反馈ID建议使用绑定重定向。添加到您的主web.config文件..

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 
     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.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.1" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
+0

感谢您的回复。我已经找到了整个解决方案,并且所有System.Web.MVC都已更改。还有其他人正在查看4.0.0.0,如System.Data.Entity。此外,错误消息提到了3.0.0.0,在解决方案中我找不到任何地方。 – Jay1b 2014-10-17 12:57:39

+0

@ Jay1b给绑定重定向一个镜头,我已更新我的帖子,以显示你将不得不添加,使其工作。 – iamkrillin 2014-10-17 13:01:50

+0

在我的文章和你的之间我已经完成了。已经从oldVersion =“4.0.0.0-4.0.0.1”设置了重定向,我将其更改为oldVersion =“3.0.0.0-4.0.0.1”,并在您尝试将其更改为oldVersion =“1.0.0.0-4.0”之后。 0.1" 。仍然没有运气。 – Jay1b 2014-10-17 13:18:06

0

我也有类似的问题,其中一个MS更新改变MVC.dll从3.0.0.0到3.0.0.1。我需要维护我的软件的各种版本,以确保兼容性,我必须将3.0.0.0 dll复制到我的项目,并在构建项目之前参考它。

0

经过深入挖掘,我发现view文件夹内的web.config指向不同的版本System.web.mvc。有一次,我从4.0.0.1 改为

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 

从System.Web.MVC的

<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 

变化版本4.0.0.0我能解决这个问题。

+0

请在'''中编码XML标签 – Alexander 2015-04-14 17:25:14