簡體   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