繁体   English   中英

找不到包含文档的“无法加载文件或程序集'System.Web.Mvc'或其依赖项之一”

[英]Can't resolve “Could not load file or assembly 'System.Web.Mvc' or one of its dependencies” with documentation found

我尝试将两个ASP.NET Web项目(一个Facebook应用程序和一个bot)部署到同一Azure网站,但是在将它们都部署后,我收到了:

无法加载文件或程序集'System.Web.Mvc'或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)

除了从头开始并将两个项目合并为一个项目(不希望重新发布)之外,我不确定我还能做什么。 到目前为止,我已经:

  1. 根据其他线程的建议,通过NuGet安装了Microsoft.AspNet.Mvc。 这两个项目的版本均为5.2.3.0
  2. 确保Web.config文件上具有5.2.3.0

博特

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>

应用

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>
  1. 在两个项目上确保将属性“ Copy Local”设置为“ True”以供参考System.Web.Mvc

这是堆栈跟踪:

[FileLoadException:无法加载文件或程序集'System.Web.Mvc'或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)

[FileLoadException:无法加载文件或程序集'System.Web.Mvc,版本= 5.2.3.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)System.Reflection.RuntimeAssembly._nLoad(AssemblyName文件名,字符串codeBase,证据AssemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔throwOnFileNotFound,布尔值用于Introspection,布尔值抑制0)
System.Reflection.RuntimeAssembly.nLoad(AssemblyName文件名,字符串codeBase,证据程序集安全性,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔值throwOnFileNotFound,布尔值用于自省,布尔值抑制安全性检查)+36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔型throwOnFileNotFound,布尔型用于自省,布尔型抑制安全检查)+152
System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,证据AssemblySecurity,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,用于自省的布尔值)+77
System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,证据AssemblySecurity,StackCrawlMark&stackMark,用于自省的布尔值)+21 System.Reflection.Assembly.Load(字符串assemblyString)+28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串assemblyName,布尔型starDirective)+38

[ConfigurationErrorsException:无法加载文件或程序集'System.Web.Mvc,版本= 5.2.3.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串assemblyName,布尔型starDirective)+738
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)+130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()+92 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath,Boolean&isRefAssemblyLoaded)+290
System.Web.Compilation.BuildManager.ExecutePreAppStart()+157
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParametershostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException)+549

[HttpException(0x80004005):无法加载文件或程序集'System.Web.Mvc,版本= 5.2.3.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)
System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+10044576 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+95 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文)+254

请尝试转到https:// [YourSiteName] .scm.azurewebsites.net / DebugConsole /?shell = powershell

并执行以下@ PowerShell提示符:

[System.Diagnostics.FileVersionInfo]::GetVersionInfo("d:\home\site\wwwroot\bin\System.Web.Mvc.dll").FileVersion

这将告诉您.Mvc.dll是什么版本。

注意:您的实时站点文件位于\\ site \\ wwwroot \\下

我决心从头开始我的Web项目,看看是否可以解决此错误。 我能够找到有关如何将两个项目部署到单个Azure网站的其他答案 这个想法是在主网站下创建一个虚拟目录,并将您的网站发布到根网站,在我的例子中是bot,发布到虚拟目录。 到目前为止,它似乎成立了!

暂无
暂无

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

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