VS 2008 Reporting Services 报告定义生成
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在再次读取之前,您必须将流重置回位置 0。否则,
LoadReportDefinition
将从流的末尾开始读取。请参阅此页<上的 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.See CreateMemoryStream() on this page
您是否尝试过将 MemoryStream 保存到单独的文件中并将其与原始文件进行比较?
Have you tried saving the MemoryStream down to a separate file and comparing it to the original?