VS 2008 Reporting Services 报告定义生成

发布于 2024-08-17 01:31:43 字数 671 浏览 7 评论 0原文

我正在使用 VS 2008 生成 Reporting Services 报告定义。问题是,每当我尝试从流加载报告定义时,都会收到错误。

我有以下代码:

var loaded = XDocument.Load(filePath);
LocalReport ret = new LocalReport();
using (var stream = new MemoryStream())
{
    var writer = new StreamWriter(stream);
    loaded.Save(writer);
    var ret = new LocalReport();
    ret.LoadReportDefinition(stream);

    var r= ret.GetParameters();
}

当执行最后一行时,它会抛出 LocalProcessingException 并带有以下文本:

{"The report definition is not valid.  Details: O elemento raiz está em falta."}

详细信息转换为“根元素丢失”。

可能出什么问题了?

编辑: XML 定义是正确的。问题出在加载定义之后的某个地方。

I'm using VS 2008 to generate a Reporting Services report definition. The problem is that whenever I try to load a report definition from a stream I get an error.

I have the following code:

var loaded = XDocument.Load(filePath);
LocalReport ret = new LocalReport();
using (var stream = new MemoryStream())
{
    var writer = new StreamWriter(stream);
    loaded.Save(writer);
    var ret = new LocalReport();
    ret.LoadReportDefinition(stream);

    var r= ret.GetParameters();
}

When the last line is executing it throws LocalProcessingException with the followinf text:

{"The report definition is not valid.  Details: O elemento raiz está em falta."}

The details translate to "root element missing".

What could be wrong?

Edit: The XML definition is correct. The problem lies somewhere after the loading of the definition.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸢与 2024-08-24 01:31:43

在再次读取之前,您必须将流重置回位置 0。否则,LoadReportDefinition 将从流的末尾开始读取。

var loaded = XDocument.Load(filePath);
LocalReport ret = new LocalReport();
using (var stream = new MemoryStream())
{
    var writer = new StreamWriter(stream);
    loaded.Save(writer);
    writer.Close();
    writer.Position = 0;
    var ret = new LocalReport();
    ret.LoadReportDefinition(stream);

    var r= ret.GetParameters();
}

请参阅此页<上的 CreateMemoryStream() /a>

You must reset the stream back to position 0 before reading it again. Otherwise LoadReportDefinition will start to read from the end of the stream.

var loaded = XDocument.Load(filePath);
LocalReport ret = new LocalReport();
using (var stream = new MemoryStream())
{
    var writer = new StreamWriter(stream);
    loaded.Save(writer);
    writer.Close();
    writer.Position = 0;
    var ret = new LocalReport();
    ret.LoadReportDefinition(stream);

    var r= ret.GetParameters();
}

See CreateMemoryStream() on this page

我的奇迹 2024-08-24 01:31:43

您是否尝试过将 MemoryStream 保存到单独的文件中并将其与原始文件进行比较?

Have you tried saving the MemoryStream down to a separate file and comparing it to the original?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文