asp.net-mvc – 无法加载文件或程序集’System.Web.WebPages.Razor’?
|
我有一个MVC5应用程序,我试图发布到Microsoft Azure Webhosting.当我在localhost上执行应用程序时,一切都按预期工作.但是,当我发布到Azure并尝试加载主机域时,我收到以下错误消息: 无法加载文件或程序集’System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35’或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配. (来自HRESULT的异常:0x80131040). 当我查看我的Web.Config文件时,我有以下内容: < sectionGroup name =“system.web.webPages.razor”type =“System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup,System.Web.WebPages.Razor,Version = 3.0.0.0,PublicKeyToken = 31BF3856AD364E35 “> 如果我从错误消息收集的内容是正确的,我的应用程序或某个组件正在寻求版本2.0.0.0而不是3.0.0.0,但我不知道是什么/可能导致该问题. 发布到Azure时是否还有其他人遇到此问题? 编辑: 正如trailmax所建议的,我在Package Manager Console中执行了Add-BindingRedirect,结果如下: PM> Add-BindingRedirect Name OldVersion NewVersion -------------- ------------ ------------- System.Web.Mvc 0.0.0.0-5.1.0.0 5.1.0.0 System.Web.WebPages 0.0.0.0-3.0.0.0 3.0.0.0 然后我检查了localhost以验证所有内容仍处于正常工作状态(检查)并尝试再次发布到Azure.仍然是同一个问题:/ 这是完整的细分: 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,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,PublicKeyToken=31bf3856ad364e35' could not be loaded. WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging,set the registry value [HKLMSoftwareMicrosoftFusion!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 [HKLMSoftwareMicrosoftFusion!EnableLog]. Stack Trace: [FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor,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.WebPages.OAuth.PreApplicationStartCode.Start() +0 [InvalidOperationException: The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor,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) +547 System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath,Boolean& isRefAssemblyLoaded) +102 System.Web.Compilation.BuildManager.ExecutePreAppStart() +153 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException) +521 [HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.Web.WebPages.OAuth.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor,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) +9930568 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext context) +254 EDIT2: 更正,主根Web.config文件已从Add-BindingRedirect修改.在发布时仍然收到同样的问题. <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.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
解决方法你的一个组件取决于v2,因此问题.您需要在web.config中添加绑定重定向,以使程序集指向v3.您可以使用命令在nuget console中执行此操作 PM> Add-BindingRedirect 如果该工具没有获取版本不匹配,您可以手动将其添加到web.config: <configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
找出哪个组件依赖于旧版本的方法之一,您可以使用依赖关系跟踪工具.我过去使用的那个叫做CheckAsm.免费版本足够一次或两次使用. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net-mvc – formcollection只保存所选的html.listbox项
- asp.net中利用Jquery+Ajax+Json实现无刷新分页的实例代码
- asp.net – 如何在网格视图列标题上添加鼠标悬停工具提示
- asp.net – 通过使用Javascript将邮政编码传递到maps.googl
- asp-classic – 如何在经典ASP中使用VBScript生成MD5?
- 如何在asp.net中获取服务器/网站的IP地址?
- .net – 在VS 2010中调试时修改代码
- asp.net – Response.TrySkipIisCustomErrors不工作
- asp.net-mvc-3 – 为MVC3应用程序配置Ninject的正确方法是什
- ASP.NET URL验证
- asp.net-mvc – 我的模型应该在哪里生活? Web层
- asp.net – IIS HTTP错误403.1 – 禁止访问:拒绝
- asp.net-mvc – ASP.net 5 MVC 6 bower.json和pr
- asp.net – Googlebot导致.NET System.Web.HttpE
- ASP.Net MVC Script Bundle导致404
- Asp.net身份密码散列
- asp.net-mvc – ASP.NET MVC自定义成员资格提供程
- 这两种方法有什么区别?
- asp.net-mvc – 如何使用ASP.NET MVC的plupload包
- asp.net-mvc – 在mvc下拉列表中自动恢复
