繁体   English   中英

从Crystal Reports Viewer进行打印和导出会引发错误

[英]Printing and exporting from Crystal Reports Viewer throws error

我正在使用.net Crystal Reports查看器以asp.net Web表单显示报告。 这可以正常工作,但是当我单击打印选项,然后在选项弹出窗口上单击“确定”时,出现以下错误:

访问被拒绝。
说明:执行当前Web请求期间发生未处理的异常。 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

异常详细信息:System.Runtime.InteropServices.COMException:访问被拒绝。

当我尝试导出时,也是一样。 我正在Visual Studio开发服务器VS2008上运行它。 我该怎么做才能纠正这个问题?

编辑:

这是一些代码。

        txtCategory: 
    <asp:TextBox ID="txtCategory" runat="server"></asp:TextBox>
    <br />
    txtFromDate:&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="txtFromDate" runat="server" TabIndex="1"></asp:TextBox>
    <br />
    txtToDate:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="txtToDate" runat="server" TabIndex="2"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="btnShowReport" runat="server" onclick="btnShowReport_Click" 
        TabIndex="4" Text="Show Report" />
    <br />
    <br />
    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">

    </CR:CrystalReportSource>
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
        AutoDataBind="True" DisplayGroupTree="False" EnableDatabaseLogonPrompt="False" 
        EnableParameterPrompt="False" HasRefreshButton="True" Height="50px" 
        ReportSourceID="CrystalReportSource1" Width="350px" />

在代码隐藏中:

protected void btnShowReport_Click(object sender, EventArgs e)
{
    ReportDocument report = new ReportDocument();
    report.Load(Server.MapPath(@"~\ReportFiles\CrystalReport.rpt"));

    report.SetParameterValue("value1", txtCategory.Text);

    ParameterRangeValue dateRange = new ParameterRangeValue();

    CrystalReportViewer1.ReportSource = report;
}



    STACKTRACE: at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) 
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) 
at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()

我不知道您的问题的确切答案,但我可以建议您看一下,希望对您有帮助。 由于这是一个访问被拒绝的错误,因此我将查看其最终访问权限:

Server.MapPath(@“〜\\ ReportFiles \\ CrystalReport.rpt”)

Google对CrystalDecisions.ReportAppServer访问被拒绝的搜索建议您可以在web.config中使用模拟来以具有读/写访问权限的用户访问该文件夹。

<authentication mode="Windows" />

<identity impersonate="true" userName="domainname\\username" password="mypassword" />

使用Windows身份验证大概可以确保使用模拟。

希望能有所帮助。

好吧,我发现了两件事:

1)我打开Visual Studio时,它开始引发错误,迫使我搜索Internet的两端并使用devenv / resetuserdata重置环境。 那是固定的部分。 我还修复了.NET安装,但是我不知道这是否起作用。

2)显然,在我的代码中将报告分配给查看器之后,我需要刷新reportviewer。

我添加了这个:

CrystalReportViewer1.RefreshReport();

在我的代码底部,中提琴! 现在,我可以导出和打印了。 那有多么简单和疯狂?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM