ReportViewer 渲染在一些执行后挂起服务器 [英] ReportViewer rendering hangs server after some executions

查看:53
本文介绍了ReportViewer 渲染在一些执行后挂起服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生成报告的服务.那部分的代码是这样的

I have a service that generates a Report. The code for that part is like this

ReportDataSource rds = new ReportDataSource();
rds.Name = "DataSetDIR";
rds.Value = dataSource;                    
using (ReportViewer rv = new ReportViewer()){
    rv.LocalReport.DataSources.Clear();
    rv.LocalReport.DataSources.Add(rds);
    rv.LocalReport.ReportEmbeddedResource = "xxxxxx.rdlc";
    rv.LocalReport.Refresh();
    byteViewer = rv.LocalReport.Render("PDF");                        
    rv.LocalReport.Dispose();
}

在我的电脑上它工作正常,但我已经将它发布到服务器上并且它工作正常......但只在几次执行期间(在我完成的不同测试中它可以从 5 到 25 不等)

On my computer it works OK, but I have published it on the server and it works OK...but only during a few executions (it can vary from 5 to 25 in differents tests I've done)

之后,它总是挂在这一行:

After that, it always hangs on this line:

byteViewer = rv.LocalReport.Render("PDF");

为了让它再次工作(直到它再次挂起),我必须重新启动应用程序池

To make it work again (until it hangs again), I have to restart Application Pool

PD:出现此问题后,当我尝试重新启动应用程序池时显示此错误

PD: After this problem appears, when I try to restart the Application Pool this error is show

我必须转到服务并重新启动凭据管理器才能重新启动应用程序池

And I have to go to the services and restart the Credential Manager to be able to restarte the ApplicationPool

知道为什么会发生这种情况,我该如何解决?

Any idea why this is happening and how can i solve it?

推荐答案

我找到了解决方案.

我只需要直接调用 LocalReport 问题就消失了.

I only had to call the LocalReport directy and the problem dissapears.

using (LocalReport lr = new LocalReport()){
    lr.DataSources.Clear();
    lr.DataSources.Add(rds);
    lr.ReportEmbeddedResource = "xxxxxx.rdlc";
    lr.LocalReport.Refresh();
    byteViewer = lr.Render("PDF");
}

这篇关于ReportViewer 渲染在一些执行后挂起服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆