c# - LocalReport 有时会在渲染时挂起
问题描述
在 C#/WPF 应用程序中生成 RDLC 报告时,有时它会挂起渲染(render
方法调用不返回)。
报告数据来自 C# 对象(预先用 PostgreSQL 数据库中的数据填充),因此此问题与 SQL 无关。
我想知道:
- 我怎样才能找出原因?
- 有什么方法可以让用户在报告生成挂起时终止它?
将报告生成嵌入到一个using
块中(如ReportViewer 渲染在某些执行后挂起服务器中所见)并没有解决问题。
using (LocalReport report = new LocalReport())
{
report.ReportPath = @"C:\Path\To\MyReport.rdlc";
// Get the report data from db and fill it into MyReportData object.
MyReportData data = CreateReportData();
ReportDataSource headerDataSource = new ReportDataSource();
headerDataSource.Name = "HeaderDataSet";
headerDataSource.Value = data.Header;
report.DataSources.Add(headerDataSource);
// Add more data sources ...
// No report parameters are being used
report.Refresh();
pdfData = report.Render("PDF"); // here it hangs sometimes
}
如上所述,render
-call 有时会挂起。杀死应用程序并再次生成完全相同的报告后,它就可以工作了。
解决方案
推荐阅读
- r - 为什么我的系统发育树与我的数据不匹配?
- spring-boot - Spring boot JPA - 插入或更新实体列表
- python - Python 从包含子字符串的大字符串列表中获取字符串的最快方法(地址自动完成)
- android - 无法访问“org.gradle.api.artifacts.dsl.RepositoryHandler”的超类型“kotlin.collections.Collection”
- excel - Excel:从具有多个条件的列中获取子数组
- python - 为什么 Tensorflow 伯努利分布总是返回 0?
- botframework - 如何根据 API 的输出创建返回一定数量卡片的逻辑
- cmake - 使用较旧的 LibTool 宏时,可替代 GET_TARGET_PROPERTY(... LOCATION)
- php - url中存在折扣券时如何自动发送?
- python - 从 Markdown 中的代码块解析标签的稳健方法