【问题标题】:Could not load file or assembly 'Microsoft.ReportViewer.WebForms' despite no references尽管没有引用,但无法加载文件或程序集“Microsoft.ReportViewer.WebForms”
【发布时间】:2018-05-19 02:12:33
【问题描述】:

我在我的 ASP.NET 项目中遇到过此错误消息,但这个最新实例确实让我感到困惑,因为在我的项目中找不到任何对 ReportViewer 的引用。寻找有关如何确定其来源的任何建议。以下是堆栈跟踪信息:

    [FileNotFoundException: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +457
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +34
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +729
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +69
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +321
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +878

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +124
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +700

【问题讨论】:

    标签: asp.net .net-assembly reportviewer


    【解决方案1】:

    许多 Asp.Net 控件需要报表查看器库的支持才能呈现输出。所以,尝试安装包Microsoft Report Viewer Redistributable,然后尝试编译解决方案。您可能在安装过​​程中或稍后无意中删除了它。

    您也可以尝试检查是否在 GAC [C:\Windows\assembly] 文件夹中列出了 [Microsoft.ReportViewer.WebForms] 和相关程序集。如果不是,则表明在您的工作站中没有隐式依赖项。

    【讨论】:

    • 问题是我在我的开发机器上的另一个 ASP.NET 项目中明确使用 ReportViewer,我之前已将其部署到同一目标 Web 服务器,并且一切正常。所以这个最新的应用程序是我要部署到服务器的第二个应用程序。它显然已经拥有所有的 ReportViewer 依赖项。由于我的新项目没有任何报告功能,因此我想尽可能消除这种错误的依赖关系。
    【解决方案2】:

    虽然我无法确定为什么会出现上述错误,但我发现了一种解决方法,方法是从我在此服务器上的其他工作应用程序中将一堆程序集复制到项目的 \bin 文件夹中。这些程序集包括:

    Microsoft.ReportViewer.*
    Microsoft.AI.Web
    Microsoft.ApplicationInsights
    Microsoft.AspNet.*
    

    ... 和其他几个。我仍然困扰着为什么这甚至是必要的,因为代码不仅在我的开发机器上运行良好,而且在我第一次部署它的另一个测试 Web 服务器上运行良好。如果我的项目没有对这些东西的可验证引用,但仍然依赖于它们,那么我希望发布工具应该确保这些依赖项与我的其余代码一起部署。

    【讨论】:

      猜你喜欢
      • 2013-05-05
      • 2011-03-13
      • 2011-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-17
      相关资源
      最近更新 更多