简体   繁体   English

升级后的ASP.NET MVC应用程序问题

[英]ASP.NET MVC application problems after upgrade

I have upgraded an ASP.NET application to MVC 4. Everything works on my local computer. 我已经将ASP.NET应用程序升级到MVC4。一切都可以在本地计算机上运行。 But when I deploy the application to a web server I get the following error message: 但是,当我将应用程序部署到Web服务器时,出现以下错误消息:

Server Error in '/' Application.
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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.WebPages.Razor, Version=2.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.WebPages.Razor, Version=2.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].


Stack Trace:


[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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)]
   System.Web.Mvc.PreApplicationStartCode.Start() +0

[InvalidOperationException: The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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).]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677

[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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).]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9164848
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016

The error message can be seen here: http://dev.aishaudio.com 错误消息可以在这里看到: http : //dev.aishaudio.com

You need to deploy a number of assemblies into the bin folder of your deployed application. 您需要将许多程序集部署到已部署应用程序的bin文件夹中。 See this blog post or google for "deploy mvc assemblies" for more info. 有关更多信息, 请参见此博客文章或有关“部署mvc程序集”的google,

The most likely cause is because you are referencing files that are only on your local machine, most likely in the GAC, and so when you deploy to the server it cannot find them. 最可能的原因是因为您引用的文件仅在本地计算机上,最有可能在GAC中,因此当您部署到服务器时,找不到文件。

Look at the properties window for your MVC references, and see if any are the GAC. 在属性窗口中查找您的MVC引用,然后查看是否有GAC。

To remedy this issue mark your reference to System.Web.Mvc as "copy local = true" in the reference's properties window. 要解决此问题,请在引用的属性窗口中将对System.Web.Mvc的引用标记为“ copy local = true”。 Then when you deploy / build installer, it will copy the referenced files into your bin folder, and so will be available on the server. 然后,当您部署/构建安装程序时,它将把引用的文件复制到您的bin文件夹中,因此将在服务器上可用。

Repeat this procedure for all MVC files. 对所有MVC文件重复此过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM