SSRS报表定义比服务器更新

41

我在 Visual Studio 2015 中使用了所有最新的更新创建了一些报告。但是,当我尝试部署这些报告时,出现以下消息:

此报表的定义无效,或不受此版本 Reporting Services 的支持。
11:40:28 错误
报表定义可能是使用较新版本的 Reporting Services 创建的,或包含根据 Reporting Services 模式
11:40:28 错误
不规范或无效的内容。详情:报表定义具有无效的目标
11:40:28 错误
命名空间 'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition',该命名空间无法升级。

.rdl 文件的前几行设置如下:

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

我能更改架构定义吗?如果可以,更改成什么?我尝试将2016更改为2014或2012,但都没有起作用。

有什么地方可以查看有效的定义吗?


1
你有访问早期版本的Visual Studio的权限吗?尝试在其中一个版本中创建报告并查看模式是什么。 - Ann L.
1
你正在运行哪个版本的部署服务器? - cp50
1
SQL报表服务器是2012版。我只安装了VS 2015。 - M Kenyon II
1
或者,您可以从报告服务器下载一个工作报告,并查看模式是什么。也许使用记事本来检查它们,这样VS就不会尝试将它们转换为新的模式。 - Ann L.
1
你不能在一个比代码将要运行的终极服务器版本更高的版本中创建东西。请安装VS2012。 - HLGEM
显示剩余2条评论
10个回答

109

我曾经遇到过类似的问题,一个需要更改的变化导致在2016中出现了"文档未记录错误/无效的RDL结构"错误,所以我编辑了RDL文件以便在早期版本中打开它并进行修改。这并不太难,但你需要做一些标签编辑。

对于新报告,您应该使用旧版本,但对于现有报告,可以执行以下操作:(我回退到了2008年)

实际上,我写了一些超级hackish的代码来做到这一点,作为博客文章的一部分,但手动编辑足够简单。


2
这个方法非常有效。@trubs,我在我的报告中没有找到“TargetServerVersion”,所以这个答案解决了我的问题,而不是其他的答案。 - MarceloBarbosa
1
嗨@MarceloBarbosa,这对我也起作用了,但是每次更改报告时我都不得不重复所有步骤。我已经添加了一个答案,并附上了屏幕截图以显示特定设置的位置(以支持Amila Pradeep的答案)。 - Trubs
2
谢谢这个好主意。对我的报告很有效 :) - Sedat Kumcu
我猜如果“TargetServerVersion”不在属性选项卡中,那可能取决于Visual Studio的版本? - Trubs
1
谢谢,这个完美地解决了问题。我现在可以将我的VS 2015报告重新打开到VS 2013中了。 - speedinfusion
从2016年到2008年,我没有删除任何“df”相关的内容(只进行了其他三个更改),但它仍然对我有效。 - LinuxDisciple

37
以下设置应根据您使用的 SSRS 版本进行设置,然后从 \bin 目录中获取 RDL 文件。
或者,在更新了 TargetServerVersion 后,只需使用 rdl 上的“右键单击 | 部署”选项即可。
接受的答案在多个版本的 SSRS 上更难/更容易出错/不太可能工作,并且需要每次更改 RDL 时应用。 输入图像描述

2
啊...谢谢! - MarceloBarbosa
2
具有讽刺意味的是,您的图像无法显示。 - Brad
1
Bin文件夹...这就是我缺少的东西。 - DBNull
2
这是最佳解决方案。谢谢。 - Tony Li

17

当我切换到VS2017并安装了报表设计器版本14.2时,我遇到了同样的问题。

对于我来说,只需要3个步骤就可以解决这个问题。

1:将xmlns更改为“http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition

2:移除标签"ReportSections"和"ReportSection"(仅限标签)。

3:删除报告的ReportParametersLayout部分。

唯一需要记住的是将xmlns指向2008/01。

在更改为2008/01并尝试运行报表后,可以在错误消息中看到另外两个步骤。


正确。我遵循这个并且在VS 2019到VS 2015上工作。 - toha

8

我最近也遇到了这个问题。我发现只需要更改问题中的.rdl文件中的两个项目。

  1. 将FROM更改为:

    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"

    将TO更改为:

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

与其他回答不同,我需要使用2010而不是2008。我建议检查您已经部署的.rdl文件。

  1. 删除“ReportParametersLayout”块。

注意:如果我删除了ReportSections块,则无法像其他人指出的那样正常工作。


8

1
非常感谢@Bruno,这解决了我的问题。对于WinForms应用程序,我们只需要安装Microsoft.ReportingServices.ReportViewerControl.Winforms包即可。 - M_Idrees

4

我曾经遇到了同样的问题,以下是我是如何解决它的:

  1. 在报告项目属性中设置"TargetServerVersion"属性为旧版报告服务器。
  2. 构建项目。
  3. 在bin文件夹中获取报告,并部署到旧版报告服务器上。

你的源报告格式和命名空间将被更新为最新版本。但是bin文件夹中的报告将被构建成与目标报告服务器版本兼容的形式。


2
这绝对是正确的方式! - VorTechS

2
最简单和直接的解决方案。我建议您在当前项目的“管理NuGet包”中找到Microsoft.ReportingServices.ReportViewerControl.WebForms,并将此dll版本更新为最新版本。
从VS菜单导航:工具 > NuGet程序包管理器 > 管理解决方案的NuGet程序包。

1

我已经自动化了这个任务。

创建一个带有名为“TextBoxFile”的文本框和按钮的表单。 在单击按钮的代码中:

    Dim xmlDoc As New XmlDocument()
    xmlDoc.Load(TextBoxFile.Text)
    Dim root = xmlDoc.DocumentElement 

    For Each elel As XmlNode In root.ChildNodes
        Debug.WriteLine(elel.Name & " " & elel.NodeType)
    Next

    If root.Attributes()("xmlns").Value <> "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" Then
        root.Attributes()("xmlns").Value = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
    End If

    Dim nsmgr = New XmlNamespaceManager(xmlDoc.NameTable)
    nsmgr.AddNamespace("bk", "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition")

    Dim autoRefreshElements = root.GetElementsByTagName("AutoRefresh")
    While autoRefreshElements.Count > 0
        root.RemoveChild(autoRefreshElements(0))
    End While

    Dim ReportParametersLayout = root.GetElementsByTagName("ReportParametersLayout")
    While ReportParametersLayout.Count > 0
        root.RemoveChild(ReportParametersLayout(0))
    End While

    Dim ReportSections = root.GetElementsByTagName("ReportSections")

    If ReportSections.Count > 0 Then
        ' Move content of ReportSections just below the block.
        Dim ReportSection = ReportSections(0).ChildNodes()

        ' First, copy the elements after
        Dim precedent = ReportSections(0)
        For Each child As XmlNode In ReportSection(0).ChildNodes
            Dim clone = child.Clone
            root.InsertAfter(clone, precedent)
            precedent = clone
        Next

        ' After deleting the existing block
        While ReportSections.Count > 0
            root.RemoveChild(ReportSections(0))
        End While
    End If

    xmlDoc.Save(TextBoxFile.Text) 

    MsgBox("Ok")

1
我在切换到VS2019并安装了Report Designer Version 14.2时遇到了同样的问题。
对我来说,只需要3个步骤来解决这个问题。
1:将xmlns更改为"http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
2:删除"ReportSections"和"ReportSection"(仅限标签)。
3:删除报告的ReportParametersLayout部分。
你唯一需要记住的是将xmlns指向2008/01。
在将xmlns更改为2008/01并尝试运行报告后,可以在错误消息中看到另外两个步骤。
分享

-2

通过本地管理员帐户登录并通过删除和创建计算机对象来纠正计算机对象。


如果您有新的问题,请点击提问按钮进行提问。如果有必要,可以包含此问题的链接以提供上下文。-【审核通过】 - Serhat MERCAN

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接