簡體   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