I have a program installed on maybe 150 computers in our company and randomly (maybe 3-4 times a week) I get the error below from some of these computers. As I said total of 3 to 4 times a week from the 500 odd times this code is run..
<Message>The handle is invalid</Message>
- <StackTrace>
<StackItem Method="System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)" LineNumber="-1" />
<StackItem Method="System.Drawing.Printing.PrintController.Print(PrintDocument document)" LineNumber="-1" />
<StackItem Method="System.Drawing.Printing.PrintDocument.Print()" LineNumber="-1" />
<StackItem Method="CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)" LineNumber="-1" />
<StackItem Method="CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)" LineNumber="-1" />
<StackItem Method="MobilePhoneSales.AL.usrContractDetails.cmdSaveContract_Click(Object sender, EventArgs e) in Z:\SVN_Repos\MobilePhoneSales\MobilePhoneSales\AL\usrContractDetails.cs" LineNumber="511" />
<StackItem Method="System.Windows.Forms.Control.OnClick(EventArgs e)" LineNumber="-1" />
<StackItem Method="DevExpress.XtraEditors.BaseButton.OnClick(EventArgs e)" LineNumber="-1" />
<StackItem Method="DevExpress.XtraEditors.BaseButton.OnMouseUp(MouseEventArgs e)" LineNumber="-1" />
<StackItem Method="System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)" LineNumber="-1" />
<StackItem Method="System.Windows.Forms.Control.WndProc(Message& m)" LineNumber="-1" />
<StackItem Method="DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)" LineNumber="-1" />
<StackItem Method="System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)" LineNumber="-1" />
<StackItem Method="System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)" LineNumber="-1" />
<StackItem Method="System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)" LineNumber="-1" />
</StackTrace>
I am running crystal reports version 12.02 and using .net 2.0, the error happens on the PrintToPrinter line of the code below.. Thanks for having a look any questions I will try and respond with as much detail as possible..
using (ReportDocument ZeroUpfrontContract = new AL.rptZeroUpfrontContract())
{
ZeroUpfrontContract.SetParameterValue("Header1", BL.HeaderRecord.m_HeaderLine1);
ZeroUpfrontContract.SetParameterValue("Header2", BL.HeaderRecord.m_HeaderLine2);
ZeroUpfrontContract.SetParameterValue("Header3", BL.HeaderRecord.m_HeaderLine3);
ZeroUpfrontContract.SetParameterValue("Header4", BL.HeaderRecord.m_HeaderLine4);
ZeroUpfrontContract.SetParameterValue("Header5", BL.HeaderRecord.m_HeaderLine5);
ZeroUpfrontContract.SetParameterValue("Stock_code", txtBarCode.Text.Length > 0 ? DL.Inventory.queryStockCode(txtBarCode.Text) : "");
ZeroUpfrontContract.SetParameterValue("descript", lblItemDescript.Text);
ZeroUpfrontContract.SetParameterValue("IMEI", txtIMEI.Text);
ZeroUpfrontContract.SetParameterValue("Comments", "Comments: " + txtComments.Text);
ZeroUpfrontContract.SetParameterValue("ContractDate", DateTime.Now);
ZeroUpfrontContract.SetParameterValue("CustName", currentCustomer.FirstName.Trim() + " " + currentCustomer.Surname.Trim());
ZeroUpfrontContract.SetParameterValue("DataPack", chkDataPlan.Checked ? cboDataPacks.Text : "Declined by customer, therefore Pay As You Go rates will be applicable.");
ZeroUpfrontContract.SetParameterValue("ETC", chkETC.Checked ? rdoETC.SelectedIndex == 0 ? "Cancellation fee of $" + txtETCValue.Text + " reoccuring for the next " + txtETCDuration.Text + " months."
: "Cancellation fee of $" + txtETCValue.Text + " on next bill."
: " ");
if (cboWarrantyCodes.SelectedIndex > -1)
{
ZeroUpfrontContract.SetParameterValue("Warranty", "1 Year Extended Warranty Included");
}
else
{
ZeroUpfrontContract.SetParameterValue("Warranty", " ");
}
ZeroUpfrontContract.PrintToPrinter(2, false, 1, 999);
}
Request clarification before answering.
Make sure the printer driver you are using is correct for;
1) The printer type it's self
2) The OS
Your code does not show if you are using .Close and .Dispose on the report objects, but this would be highly recommended.
Make sure you are using SP1:
https://smpdl.sap-ag.de/~sapidp/012002523100006007872008E/crvs05sp1.exe
The above will update your dev computer and install new MSI file that you should use to deploy the SP 1 (SP1 will not install on runtime computers. Only the MSI will):
c:\program files\microsoft visual studio 8\sdk\v2.0\bootstrapper\packages\crystal reports\CRRedist2005_x86.msi
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, thanks for the feedback..
1) I am certain the printer driver is OK and we have other programs on those computers (though not using crystal) and they all print fine as does 99% of print jobs sent through crystal, just from time to time we get that error..
2) I am using dispose (please note the report object is created with a "using" statement)..
3) We are running crystal reports version 12.2.0.290 with Visual Studio 2008.. Is that redistributable still relevant???
Sorry, missed the ref re. CR 12
We definitely want to go with SP 3 for CR 2008:
https://smpdl.sap-ag.de/~sapidp/012002523100007123572010E/cr2008_sp3.exe
Then apply FP 3.2:
https://smpdl.sap-ag.de/~sapidp/012002523100015106822010E/cr2008fp32.exe
Then make sure you are deploying the correct runtime.
MSM:
https://smpdl.sap-ag.de/~sapidp/012002523100015106812010E/cr2008fp32_mm.zip
MSI:
https://smpdl.sap-ag.de/~sapidp/012002523100015160662010E/cr2008fp32_redist.zip
There have been a lot of fixes re. printers between SP 2 (which is what you are on and FP 3.2).
- Ludek
Hello,
I think the issue is not solved unless the user had a workaround. And if so I 'd like to receive that. The redistributable that we are using is cr2008fp35_redist.zip.
The evironment is a 2008 64 bit server that is used for the crystal report generation in a 32 bit application. The printservers that host the printers are 2003 32 bit servers. The first printserver is connected to the 64 bit 2008 using ThinPrint and from there it connects through to the 2003 printserver with the specific drivers for all printers. If you don't know ThinPrint it 's an application used to shrink the spooled fill for less networktraffic.
I receive the following error:
Message:The handle is invalid
Source: System.Drawing Stacktrace: at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) at System.Drawing.Printing.PrintController.Print(PrintDocument document) at System.Drawing.Printing.PrintDocument.Print() at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN)
Kind regards,
Koen Stoops
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.