报告定义具有无效的目标命名空间rsInvalidReportDefinition

Ani*_*n J 18 sql-server visual-studio reporting-services ssrs-2012 sql-server-2012-datatools

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

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

小智 61

编辑:TargetServerVersion只要您没有使用任何2016功能,您设置为属性的报告的特定版本就会在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">
Run Code Online (Sandbox Code Playgroud)

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

  <ReportSections>
    <ReportSection>
Run Code Online (Sandbox Code Playgroud)

还有这些...

    </ReportSection>
  </ReportSections>
Run Code Online (Sandbox Code Playgroud)

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

  <ReportParametersLayout>
    <GridLayoutDefinition>
      <NumberOfColumns>4</NumberOfColumns>
      <NumberOfRows>2</NumberOfRows>
    </GridLayoutDefinition>
  </ReportParametersLayout>
Run Code Online (Sandbox Code Playgroud)

点击保存,返回设计并运行报告.如果您尚未修改设计,它将在SQL2014中工作.您更改任何字段的那一刻它将恢复为2016架构.

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

  • 谢谢!你是个巫师.这已经让我们吵了一段时间了. (2认同)
  • 当您构建报告时,它会将您 _targeted_(在 TargetServerVersion 属性中)的正确 xml 版本放入 \bin 文件夹中。您需要将其 **_that_** 文件上传到您的服务器(不是您正在编辑的文件),并且命名空间和功能将没问题。(注意 - \bin 目录中的文件是使用 [右键单击部署] 时部署的 rdl) (2认同)

小智 7

我编写了一个简单的 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"
Run Code Online (Sandbox Code Playgroud)

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


Phi*_*ker 6

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

  1. 在项目的“属性页”中,将设置TargetServerVersion为所需的格式(在这种情况下为SQL Server 2008 R2, 2012 or 2014
  2. 建立项目
  3. 查找在生成输出文件夹所需格式的RDL的(在项目属性页中指定也:Build => OutputPath