29

在我一周前更新我的机器之前,我有一个 MVC 项目一直运行良好。我现在在尝试运行项目时收到绑定错误

托管调试助手“BindingFailure”在“C:\Program Files (x86)\IIS Express\iisexpress.exe”中检测到问题。

附加信息:显示名称为“Microsoft.VisualStudio.Web.PageInspector.Runtime”的程序集未能在 ID 为 2 的 AppDomain 的“LoadFrom”绑定上下文中加载。失败的原因是:System.IO.FileNotFoundException:可能不加载文件或程序集 'Microsoft.VisualStudio.Web.PageInspector.Runtime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。该系统找不到指定的文件。

如果我继续通过错误,项目将正确加载。但是,当我将项目作为云服务中的 Web 角色运行时,它不会运行,因为它会不断弹出角色花费的时间比预期的要长.... 消息

我假设这与作为独立项目运行时的绑定问题有关

有没有人遇到过这个?


编辑我在配置文件中搜索了程序集参考,没有出现。最终我只是重新安装了新的 azure SDK。加载时仍会弹出带有 pageinspector 的绑定错误消息,但如果我继续该项目,它工作正常。目前,我将不得不忍受这个烦人的消息,直到找到解决方案

4

4 回答 4

28

我在安装了 Visual Studio 2013 的机器上观察到了这种情况。

据我所知,它在 VS2013 更新 4 之后开始发生。

(它可能以前发生过,但这对我的环境来说是新的)

我在 GAC 中找到了这个程序集(两个版本,一个用于 VS2012,另一个用于 VS2013)但这些版本(显然)具有“12.3.0.0”版本的强名称(请注意,上述分辨率错误是针对“版本” 14" 组件。)

这是此特定异常的第一个实例的调用堆栈:

mscorlib.dll!System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName fileName, string codeBase, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly locationHint, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) + 0x23 bytes   
mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) + 0x99 bytes   
mscorlib.dll!System.Reflection.Assembly.Load(System.Reflection.AssemblyName assemblyRef) + 0x25 bytes   
Microsoft.VisualStudio.Web.PageInspector.Loader.dll!Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader.GetRuntimeAssembly(out System.Reflection.Assembly runtime) + 0xdb bytes   
Microsoft.VisualStudio.Web.PageInspector.Loader.dll!Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader.LoadRuntime() + 0x2a bytes    
Microsoft.VisualStudio.Web.PageInspector.Loader.dll!Microsoft.VisualStudio.Web.PageInspector.Runtime.Loader.RuntimeLoader.PreApplicationStart() + 0x27 bytes    
[Native to Managed Transition]  
System.Web.dll!System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(System.Collections.Generic.ICollection<System.Reflection.MethodInfo> methods, System.Func<System.IDisposable> setHostingEnvironmentCultures) + 0x142 bytes 
System.Web.dll!System.Web.Compilation.BuildManager.InvokePreStartInitMethods(System.Collections.Generic.ICollection<System.Reflection.MethodInfo> methods) + 0x5a bytes 
System.Web.dll!System.Web.Compilation.BuildManager.CallPreStartInitMethods(string preStartInitListPath, out bool isRefAssemblyLoaded) + 0x67 bytes  
System.Web.dll!System.Web.Compilation.BuildManager.ExecutePreAppStart() + 0x9a bytes    
System.Web.dll!System.Web.Hosting.HostingEnvironment.Initialize(System.Web.Hosting.ApplicationManager appManager, System.Web.Hosting.IApplicationHost appHost, System.Web.Configuration.IConfigMapPathFactory configMapPathFactory, System.Web.Hosting.HostingEnvironmentParameters hostingParameters, System.Security.Policy.PolicyLevel policyLevel, System.Exception appDomainCreationException) + 0x20a bytes   
System.Web.dll!System.Web.Hosting.HostingEnvironment.Initialize(System.Web.Hosting.ApplicationManager appManager, System.Web.Hosting.IApplicationHost appHost, System.Web.Configuration.IConfigMapPathFactory configMapPathFactory, System.Web.Hosting.HostingEnvironmentParameters hostingParameters, System.Security.Policy.PolicyLevel policyLevel) + 0x16 bytes 
[Appdomain Transition]  
System.Web.dll!System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(string appId, System.Web.Hosting.IApplicationHost appHost, System.Web.Hosting.HostingEnvironmentParameters hostingParameters) + 0x12f3 bytes 
System.Web.dll!System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(string appId, System.Web.Hosting.IApplicationHost appHost, System.Web.Hosting.HostingEnvironmentParameters hostingParameters) + 0x25 bytes    
System.Web.dll!System.Web.Hosting.ApplicationManager.GetAppDomainWithHostingEnvironment(string appId, System.Web.Hosting.IApplicationHost appHost, System.Web.Hosting.HostingEnvironmentParameters hostingParameters) + 0x6c bytes  
System.Web.dll!System.Web.Hosting.ApplicationManager.CreateObjectInternal(string appId, System.Type type, System.Web.Hosting.IApplicationHost appHost, bool failIfExists, System.Web.Hosting.HostingEnvironmentParameters hostingParameters) + 0x4d bytes   
System.Web.dll!System.Web.Hosting.ProcessHost.StartApplication(string appId, string appPath, out object runtimeInterface) + 0x18f bytes 
[Native to Managed Transition]  

这表明问题出在微软(而不是我在程序集、应用程序或机器配置中所做的事情。)

我抽查了我的所有配置(字面意思是,所有,我的项目的 web.config 以及所有 .NET 运行时机器配置,所有版本/平台),我在任何地方都找不到对这个程序集的引用。

为了解决这个错误(微软需要解决),我在我的 web.config(不是我的机器配置)中添加了一个程序集绑定重定向,如下所示:

  <dependentAssembly>
    <assemblyIdentity name="Microsoft.VisualStudio.Web.PageInspector.Runtime" publicKeyToken="b03f5f7f11d50a3a" />
    <bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="12.3.0.0" />
  </dependentAssembly>

这表明 Microsoft 发布了 Visual Studio 或类似版本的构建,它与这些程序集的未来未发布版本绑定。

希望这对其他人有帮助!

于 2015-01-07T14:57:24.760 回答
8

如果您在异常选项中取消选中抛出的异常,它应该停止提示您。我猜这是正常运作的一部分。我注意到了同样的事情。

于 2014-10-03T19:30:08.877 回答
7

尝试将其添加到 web.config 文件中,而不是更改框架文件:

<system.web>
    <httpRuntime targetFramework="4.5" />
        <compilation debug="true" targetFramework="4.5" >
          <assemblies>
            <remove assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, 
               Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          </assemblies>
        </compilation>
    ...
</system.web>
于 2015-03-10T19:55:57.530 回答
-2

我们在将 ASP.NET 生成的程序集从开发人员机器部署到生产环境时遇到了类似的问题(指的是为在运行时编译的 .ascx 和 .aspx 控件生成的程序集)。

我们正在(hackishly)从 ASP.NET 临时编译文件夹(即“C:/Users/[USER]/AppData/Local/Temp/Temporary ASP.NET Files/”)复制和持久化此类运行时生成的程序集,以避免重新编译随着服务启动,以提高性能。但是,使用在开发机器上编译的程序集会引入对 VisualStudio 程序集的依赖关系。

我们通过让生产环境自行生成这些程序集来修复它。我们正在复制并保留这些“生产”程序集,而问题完全消失了。

确保您没有如此笨拙地使用 ASP.NET 生成的程序集,它可能会修复它。

于 2014-12-11T22:33:35.253 回答