通过呈现报告的LocalProcessingException

通过呈现报告的LocalProcessingException,exception,pdf,visual-studio-2013,render,rdlc,Exception,Pdf,Visual Studio 2013,Render,Rdlc,这是我第一次在VisualStudio(2013)rdlc报告中使用C#。调用Render()方法时,它会引发LocalProcessingException 代码 我正在使用WebApi开发一个WebApplication。我需要一个流中的pdf文件,以便将其返回给客户端 我做错了什么 编辑: 我认为stream变量有问题,因为当我检查它时,我看到ssss.ReadTimeout抛出了一个System类型的异常。invalidooperationexception和ssss.ReadTimeo

这是我第一次在
VisualStudio(2013)
rdlc报告中使用C#。调用Render()方法时,它会引发LocalProcessingException

代码

我正在使用WebApi开发一个WebApplication。我需要一个流中的pdf文件,以便将其返回给客户端

我做错了什么

编辑:


我认为
stream
变量有问题,因为当我检查它时,我看到
ssss.ReadTimeout抛出了一个System类型的异常。invalidooperationexception
ssss.ReadTimeout抛出了一个System类型的异常。invalidooperationexception
但我不知道它是什么意思。

你需要使用
ReportViewer
而不是调用
LocalReport
直接的

ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = "Reports.Test.rdlc";
reportViewer.LocalReport.DataSources.Add(myDataSource);

byte[] bytes = reportViewer.LocalReport.Render("PDF");

我刚发现问题所在。我遗漏了以下一行:

report.DataSources.Add(new ReportDataSource("MyClass", new List<MyClass>() { new MyClass(){MyProp="2"}}));
report.DataSources.Add(newreportdatasource(“MyClass”,newlist(){newmyclass(){MyProp=“2”}}));

添加了这一行它的工作

什么例外?正如你在文章中提到的两个不同的。它在哪里抛出?与我的示例相同:LocalProcessingException Render()
LocalProcessingException
是使用
LocalReport
的最常见错误:您必须检查其
InnerException.Message
以了解有关该问题的更多信息。InnerException:
ProcessingAbortedException{“报表处理过程中发生错误。”}
InnerException.InnerException.Message
?每个
异常都可能有一个
InnerException
:分析它们,直到找到有用的内容。刚刚发现问题。。。
report.DataSources.Add(new ReportDataSource("MyClass", new List<MyClass>() { new MyClass(){MyProp="2"}}));