【问题标题】:The report definition has an invalid target namespace rsInvalidReportDefinition报告定义具有无效的目标命名空间 rsInvalidReportDefinition
【发布时间】:2016-03-28 22:48:32
【问题描述】:

我使用 Visual Studio 数据工具 2015 创建了一个 ReportProject。当我使用报告向导创建 report.rdl 文件时,rdl 文件具有 2016 年的架构。我的报告服务器版本为 12.0.4213.0。

如何创建与我的报告服务器兼容的 report.rdl。我尝试通过右键单击项目-> 属性并将 targetserverversion 更改为“Sql server 2008 R2、2012 或 2014”来更改 TargetServerVersion。但这也不起作用。

【问题讨论】:

    标签: sql-server visual-studio reporting-services ssrs-2012 sql-server-2012-datatools


    【解决方案1】:

    编辑:只要您不使用任何 2016 功能,您设置为 TargetServerVersion 属性的报告的特定版本就会在 BIN(\debug 或您构建到的任何位置)文件夹中创建。

    我试图找到相同的答案。您会认为只需按照您所做的方式设置解决方案的 TargetServerVersion 就会导致它使用正确的报告定义(或者他们可以选择让您选择添加 2016 年之前的报告项目)

    在此之前,如果您右键单击 .rdl 并“查看代码”,您可以更改以下几行以使其在 SQL 2014 中工作 - 只需备份您的原始 .rdl 以防出错:

    1) 将报告 xmlns 行替换为以下内容:

    <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
    

    2) 删除 ReportSections 和 ReportSection 行,保留其下方的子树结构体标签等)。所以删除这些:

      <ReportSections>
        <ReportSection>
    

    还有这些……

        </ReportSection>
      </ReportSections>
    

    3) 删除整个 ReportParametersLayout 部分。所以(例如)删除这个:

      <ReportParametersLayout>
        <GridLayoutDefinition>
          <NumberOfColumns>4</NumberOfColumns>
          <NumberOfRows>2</NumberOfRows>
        </GridLayoutDefinition>
      </ReportParametersLayout>
    

    点击保存,返回设计并运行报告。如果您没有修改设计,它将在 SQL2014 中工作。在您更改任何字段的那一刻,它将恢复为 2016 模式。

    如果有人找到解决此问题的方法,请告诉我们。谢谢!

    【讨论】:

    • 谢谢!你是个巫师。这已经让我们绊倒了一段时间了。
    • 当您构建报告时,它会将您定位(在 TargetServerVersion 属性中)的正确 xml 版本放入 \bin 文件夹。您需要将其 那个 文件上传到您的服务器(不是您正在编辑的文件),并且名称空间和功能都可以。 (注意 - \bin 目录中的文件是使用 [右键单击部署] 时部署的 rdl)
    • 英雄解决方案。谢谢。
    【解决方案2】:

    您可以通过以下步骤从 Visual Studio 中获取多种不同版本格式的报告:

    1. 在项目属性页中将TargetServerVersion 设置为所需格式(在本例中为SQL Server 2008 R2, 2012 or 2014
    2. 构建项目
    3. 在构建输出文件夹中找到所需格式的 rdl(在项目属性页中也指定:Build =&gt; OutputPath

    【讨论】:

    • 这是正确的答案,我总是在项目根文件夹中选择 rdl,但它是输出中为我的服务器获取正确命名空间/版本的那个!干杯!
    【解决方案3】:

    我编写了一个简单的 PowerShell 脚本,遵循公认答案的想法。

    $file = (Get-Content "InputFileNameHere.rdl") 
    
    # Unwraps the Body and the Page element. 
    # Simple string replacement
    $file = $file -replace '<ReportSections>',""
    $file = $file -replace '<ReportSection>',""
    $file = $file -replace '</ReportSection>',""
    $file = $file -replace '</ReportSections>',""
    
    # Parse the XML doc
    $xml = [xml]$file;
    
    # Set the XML namespace
    $xml.Report.xmlns = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition";
    
    # Delete ReportParametersLayout node    
    $xml.Report.RemoveChild($xml.Report.ReportParametersLayout);
    
    # Save the file
    Set-Content -Value $xml.OuterXml -Path "OutputFilenameHere.rdl"
    

    编辑第一行以匹配您的输入文件和最后一行,将其另存为 something.ps,运行并上传新文件。

    【讨论】:

    • 谢谢,这很有用。它也适用于 RDLC 文件,例如我正在使用的文件。我建议将文件的路径放在一个变量中,然后从脚本(如 PS1 文件)运行它:$path = "$PSScriptRoot\Invoice.rdlc"$file = (Get-Content $path)
    【解决方案4】:

    尝试我在此链接上找到并为我工作的这一步: Error while uploading a report

    1. 在 2016 年使用 SSDT,将目标 sql 版本设置为 SQL Server 2008 R2、2012 或 2014
    2. 清洁溶液
    3. 重建解决方案
    4. 复制你的 Bin\debug 文件夹的内容并用它替换主文件夹的内容(一定要备份)
    5. SSRS 2010 应该呈现您的项目

    【讨论】:

    • 你绝对的天才,非常感谢你为我减轻了很多压力!
    【解决方案5】:

    在我的情况下,当我在 RDLC Design 中添加参数时,系统在运行时抛出异常,报告定义具有无效的目标命名空间。 我刚刚卸载了 Microsot 报告查看器 v 12.0 并从当时最新的 nugetpackages 版本 15 安装了 Microsoft.ReportingServices.ReportViewerControl.Winforms Atfer 安装我的问题已解决 花了整整一夜才弄清楚。 发生问题是因为我有 VS 17 并且我使用的是旧版本的报表查看器。

    【讨论】:

      【解决方案6】:

      将第二行包含2016的报告代码替换为:

      <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
      

      然后找到ReportParametersLayout 部分并将其删除。按减号显示一行并右键单击并剪切。

      上面修复了四个报告从 Crystal 转换到版本 16,而我应该选择版本 10

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-11-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-18
        • 1970-01-01
        相关资源
        最近更新 更多