无法使用找到的文档解析“无法加载文件或程序集'System.Web.Mvc'或其中一个依赖项”

时间:2017-08-14 07:18:37

标签: c# asp.net-mvc facebook botframework

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

  

无法加载文件或程序集“System.Web.Mvc”或其中一个   依赖。定位程序集的清单定义没有   匹配程序集引用。 (HRESULT异常:0x80131040)

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

  1. 按照其他主题中的建议,通过NuGet,Microsoft.AspNet.Mvc安装。这两个项目都有版本5.2.3.0
  2. 确保Web.config文件上有5.2.3.0
  3. 博特

      <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
    2. 这是堆栈跟踪:

        

      [FileLoadException:无法加载文件或程序集'System.Web.Mvc'   或其中一个依赖项。定位程序集的清单定义   与装配参考不匹配。 (HRESULT的例外情况:   0x80131040)]

           

      [FileLoadException:无法加载文件或程序集'System.Web.Mvc,   Version = 5.2.3.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或   其中一个依赖项。定位程序集的清单定义   与装配参考不匹配。 (HRESULT的例外情况:   0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName   fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly   locationHint,StackCrawlMark&amp; stackMark,IntPtr pPrivHostBinder,   Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+0
        System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,String   codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+36
        System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName   assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+152
        System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,   证据集合安全,StackCrawlMark&amp; stackMark,IntPtr   pPrivHostBinder,Boolean forIntrospection)+77
        System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,   证据集合安全,StackCrawlMark&amp; stackMark,布尔   forIntrospection)+21 System.Reflection.Assembly.Load(String   assemblyString)+28
        System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串   assemblyName,布尔starDirective)+38

           

      [ConfigurationErrorsException:无法加载文件或程序集   'System.Web.Mvc,Version = 5.2.3.0,Culture = neutral,   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&amp; isRefAssemblyLoaded)+290
        System.Web.Compilation.BuildManager.ExecutePreAppStart()+157
        System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager   appManager,IApplicationHost appHost,IConfigMapPathFactory   configMapPathFactory,HostingEnvironmentParameters hostingParameters,   PolicyLevel policyLevel,Exception appDomainCreationException)+549

           

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

2 个答案:

答案 0 :(得分:0)

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

执行以下@ PowerShell提示符:

<master ip>:18080

这将告诉您.Mvc.dll的版本。

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

答案 1 :(得分:0)

我决定从头开始我的网络项目,看看能否解决这个错误。我能够找到关于如何将两个项目部署到单个Azure网站的other answer。我们的想法是在主网站下创建一个虚拟目录,并将您的网站发布到根网站,在我的情况下是僵尸网站,发布到虚拟目录。到目前为止,它似乎持有!