【问题标题】:Unable to run reports in WinForm application无法在 WinForm 应用程序中运行报表
【发布时间】:2020-01-28 17:48:52
【问题描述】:

当我尝试打开包含 Report Viewer 控件的表单时,它会显示以下消息:

本地报告处理过程中发生错误。

定义无效。详细信息:报表定义的目标命名空间无效

"http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" 无法升级。

rdlc文件的头是:

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">

参考集对我来说似乎是正确的:

Microsoft.ReportViewer.WinForms
Runtime version: v2.0.50727
Version: 10.0.0.0

目标框架是:.NET Framework 4.5

也许因为这是一个升级的应用程序,它仍然包含作为先决条件:

Microsoft Visual Studio 2008 报告查看器

我可以找到一篇支持文章,说明您可以将架构版本修改为 2008,但这会带来很多编译错误。

那么,如何解决呢?

【问题讨论】:

  • 参考已经很老了。我正在使用 v15.0.0,在 VS 2019 中使用 Microsoft.ReportingServices.ReportViewerControl.Winforms 包。
  • 对于 VS 2019 中的 .NET 4.5,我尝试了 "Microsoft.ReportingServices.ReportViewerControl.Winforms" version="140.337.80" targetFramework="net45" 它依赖于 "Microsoft.SqlServer.Types" version="14.0.314.76" targetFramework="net45" 没有任何问题。它是报表查看器 14.0.0。报告的架构版本:schemas.microsoft.com/sqlserver/reporting/2008/01/…" xmlns:rd="schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  • 另一件事是,架构 2008 的报告定义与架构 2016 不同。例如,对于架构 2016,它应该具有如下所示的 ReportSection:
  • schemas.microsoft.com/sqlserver/reporting/2016/01/…" xmlns:rd="schemas.microsoft.com/SQLServer/reporting/reportdesigner"> 6.5in2intrue报告>
  • @RezaAghaei:非常感谢!周末会检查这个。

标签: .net winforms visual-studio-2019 reportviewer


【解决方案1】:

当您使用最新的报告架构时,您使用的参考资料已经很旧了。您需要使用以下一个或两个选项:

  • 您可以将所有报告更改为较低的架构版本
  • ReportViewer 控件和.NET 框架升级到更高版本。

前者不仅仅是更新架构版本,因为旧架构版本不支持一些新标签,例如ReportSectionsReportSection。为此,您可以查看this post

如果您的报告已使用有效架构 2016 创建,则后者更好。然后您可以更新ReportViewer 控件和.NET Framework:

您应该确保您在项目中使用的所有其他引用和包都与您将使用的 .NET 框架版本兼容。

要进一步了解最新版本的报表查看器控件,请查看:

【讨论】:

    猜你喜欢
    • 2014-05-15
    • 1970-01-01
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 2012-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多