Crystal Reports PrintToPrinter error after the project was released to IIS

0

I use Crystal Reports to print PDF file in my ASP web project. The print function is correct when I debug and release the project in VS, but there is an error when I put the project to IIS in my computer.

I have tried to suppress the interference from database. I just use a empty crystal report with a text and no data. I also tried to use the same report and same code in a C# desktop application. The print function is correct.

There are some code in my project:

private void OutExportExcel_WJKP()
{
        // load
        string reportPath = "D:\\fileCode\\VSworkspace\\LJZY\\LJZY.WEB\\Reports\\CrystalReport11.rpt";
        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc =
                    new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        rptDoc.Load(reportPath);

        // print
        rptDoc.PrintToPrinter(1, false, 0, 0);
 }

Expected result: Pop up a window to confirm for printing the PDF report.

Actual result: The error information and code snippet is shown below:

Annotation: The error information is translated by me. Because I don't know how to change the language of error information. The original error information is in the figure below.
enter image description here

"/"Server error in application.
The specified program could not be found.
Note: an unhandled exception occurred during the execution of the current Web request.Check the stack trace information for details about the error and where in the code the error originated.
Exception details: System.ComponentModel.Win32Exception: The specified program could not be found.
Source error:
Line 134:
Line 135: // print
Line 136: rptDoc.PrintToPrinter(1, false, 0, 0);
Line 137: }
Line 138:
Source file: D:\fileCode\VSworkspace\LJZY\LJZY.WEB\Page\DownLoad\DownLoad.aspx.cs Line: 136
The stack trace:
[Win32Exception (0x80004005): The specified program could not be found.]
System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) +242489
System.Drawing.Printing.PrintController.Print(PrintDocument document) +208
System.Drawing.Printing.PrintDocument.Print() +111
CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) +469
CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) +73
LJZY.WEB.Page.DownLoad.DownLoad.OutExportExcel_WJKP() in D:\fileCode\VSworkspace\LJZY\LJZY.WEB\Page\DownLoad\DownLoad.aspx.cs:136
LJZY.WEB.Page.DownLoad.DownLoad.btn_down_Click(Object sender, EventArgs e) in D:\fileCode\VSworkspace\LJZY\LJZY.WEB\Page\DownLoad\DownLoad.aspx.cs:54
LJZY.WEB.Page.DownLoad.DownLoad.Page_Load(Object sender, EventArgs e) in D:\fileCode\VSworkspace\LJZY\LJZY.WEB\Page\DownLoad\DownLoad.aspx.cs:43
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
Version Information: Microsoft .NET Framework version:4.0.30319; ASP.NET version:4.7.3282.0

c#
asp.net
.net
crystal-reports
asked on Stack Overflow Apr 5, 2019 by YuZhang

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0