gpt4 book ai didi

asp.net-mvc-3 - 已发布的 MVC3 应用程序结果为 : "Could not load file or assembly ' System. Web.Mvc'”

转载 作者:行者123 更新时间:2023-12-02 03:42:52 25 4
gpt4 key购买 nike

我正在尝试将新的 MVC3 项目部署到 Azure 网站。

步骤:

  1. 使用 Razor View Engine 在 VS 2012 中创建新的 MVC3 Internet 应用程序。添加到 web.config 文件。
  2. F5 可在本地构建和调试,验证网站是否在本地调试中加载。
  3. 创建新的 Azure 网站并下载该网站的发布设置文件。
  4. 使用第 3 步中下载的发布设置发布网站。

预期>> 网站在发布时按预期加载。

实际>> “无法加载文件或程序集“System.Web.Mvc,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。找到的程序集的 list 定义不匹配程序集引用。”(下面是完整的堆栈跟踪)

我知道示例项目过去为我开箱即用地发布,没有任何错误,但我已经有一年左右的时间没有尝试了。

我在 Stackoverflow 上看到过一些类似的错误,但答案要么不相关,要么不完整:

我已经为此追寻了很长时间。有人有什么建议吗?

    Server Error in '/' Application.
--------------------------------------------------------------------------------


Could not load file or assembly 'System.Web.Mvc, Version=4.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=4.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=4.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.Mvc, Version=4.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)]
Microsoft.Web.Mvc.ViewEngineFix.PreAppStart() +0

[InvalidOperationException: The pre-application start initialization method PreAppStart on type Microsoft.Web.Mvc.ViewEngineFix threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc, Version=4.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.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +550
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +90
System.Web.Compilation.BuildManager.ExecutePreAppStart() +140
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

[HttpException (0x80004005): The pre-application start initialization method PreAppStart on type Microsoft.Web.Mvc.ViewEngineFix threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc, Version=4.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) +9877836
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext

最佳答案

在您的问题中,您声明您的目标是 MVC3,但看起来 Azure 计算机找不到该程序集的正确版本。它正在查找 MVC 二进制文件。这让我相信您尝试发布到的服务器上没有安装 MVC3。

有几个选项可供您选择:

  1. Upgrade your project to MVC4 and publish the upgraded version .
  2. web.config 中应用一组 BindingRedirects to redirect MVC3 to MVC4 at runtime

这是我认为您需要的一组绑定(bind)重定向,可能还有其他重定向,但每个重定向都会出现类似的错误:

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

关于asp.net-mvc-3 - 已发布的 MVC3 应用程序结果为 : "Could not load file or assembly ' System. Web.Mvc'”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20853726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com