Link to home
Start Free TrialLog in
Avatar of M0m0nga
M0m0nga

asked on

ASP.NET,Crystal Reports 10 - DHTML viewer printing error

ASP.NET,Crystal Reports 10 - DHTML viewer printing error

Hi, I'm developing an ASP.NET web application using Visual Studio 2003 and Crystal Reports 10.

I have a page with the DHTML CrystalReportViewer control on it. It works great, except when I try to print using the Client Side Printing button on the ASP.NET Web CrystalReportViewer, I get the following error:

"An communication error occurred. Printing will be stopped."


NOTE:
A google search revealed this document:
http://ftp1.businessobjects.com/webprod/hot_fixes/en/cr10win_en_sp1.pdf

Which documents a similar error message, and says its been fixed by a patch:
_______________________________

ADAPT00273670 Patch ID: 36163993
Description:
When a backslash character ("\") in a parameter is appended to a URL, the backslash is lost when a user attempt to print through
the ActiveX Print Control. Then, the following error appears: "Crystal Print Control. A communication error occurred. Printing will
be stopped."
The cause of the problem is that the query string is not encoded and, as a result, the backslashes are truncated.
New Behavior:
The URL is properly encoded. This problem is resolved.
_______________________________

So I have now ALREADY INSTALLED Crystal Enterprise 10 Service Pack 1. But, I still get the error. I've also installed the latest Hot fixes for Crystal 10 and for the Crystal Viewers. But, I still get the error.


ALSO NOTE:
The print button on the sample page works fine, so it's surely something in my code...?


Any ideas?

-Michael
Avatar of Mike McCracken
Mike McCracken

Post your code.

mlmcc
Avatar of M0m0nga

ASKER

Good Point mlmcc:

''''''''''''''''''''''''''''''''''''''''''''''''''''''
'PAGE
''''''''''''''''''''''''''''''''''''''''''''''''''''''
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ReportHtml.aspx.vb" Inherits="insureIT.ReportHtml"%>
<%@ Register TagPrefix="cr" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=10.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <title>ReportHtml</title>
            <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
            <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
            <meta name="vs_defaultClientScript" content="JavaScript">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
      </HEAD>
      <body style="MARGIN:1px">
            <form id="Form1" method="post" runat="server">
                  <div runat="server" id="divCrv" class="CrystalViewerFrame">
                        <CR:CrystalReportViewer id="CrystalReportViewer1" runat="server" AutoDataBind="true"></CR:CrystalReportViewer>
                  </div>
            </form>
      </body>
</HTML>








''''''''''''''''''''''''''''''''''''''''''''''''''''''
' CODE BEHIND
' uses a custom class that just returns a ready-made logged-on report (the custom class works fine
' without this printing issue in another page, so custom class is not the problem. Passing in parameters
' in URL has been ruled out as a cause too, I tried it a different way already.
''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Class ReportHtml
      Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

      'This call is required by the Web Form Designer.
      <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

      End Sub
      Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
      Protected WithEvents divCrv As System.Web.UI.HtmlControls.HtmlGenericControl

      'NOTE: The following placeholder declaration is required by the Web Form Designer.
      'Do not delete or move it.
      Private designerPlaceholderDeclaration As System.Object

      Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()



      End Sub

#End Region

      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim rptFilePath As String = Server.MapPath("") & "\" & ConfigurationSettings.AppSettings("reportFilePath")

            Dim report As New CustomReport(Request.QueryString)
            report.Load(rptFilePath)

            With CrystalReportViewer1
            .ReportSource = report.Report
                  .DisplayToolbar = True

                  'toolbar buttons
                  .HasPrintButton = True
                  .HasExportButton = True
                  .HasCrystalLogo = False
                  .HasRefreshButton = False
                  .HasViewList = False
                  .HasZoomFactorList = False
                  .HasToggleGroupTreeButton = False
                  .HasViewList = False
                  .HasSearchButton = False
                  .HasGotoPageButton = False
                  .HasPageNavigationButtons = False
                  .HasDrillUpButton = False

                  .DisplayGroupTree = False
                  .PageZoomFactor = 65                   

                  .PrintMode = CrystalDecisions.Web.PrintMode.ActiveX



            End With

      End Sub

End Class
listening
Avatar of M0m0nga

ASKER

ANSWER:
Solved it myself.

This error was occurring internally in the ActiveX viewer, but when I did a bit more debugging in my own ASP.NET code I discovered it was catching an error in my code.

Although the error message gave no indication of this, what was actually happening was the ActiveX print control or maybe that little launching page was posting back and forth with my code.

I stepped through and found that when I set report parameters (I was setting them from request.querystring values) I was picking up 2 extra values added to the querystring by the print control. I was sending them to the report as parameters. The report sent a "parameter not found" style error back to my code, but the crystal print control caught it, ignored the actual error, and displayed a generic error.

/* begin rant */
Sound familiar to anyone? how about the famous "Login Failed" error, that is often unrelated to logins? Has anyone else written an email to Crystal about making their error messages more descriptive? I encourage anybody who reads this to do so. It'll save thousands of programmers hours.
/* end rant */

So in the end, solutions to this error may involve simply debugging your code with a fine-tooth comb (after you've applied all the latest patches from the Crystal support site).
ASKER CERTIFIED SOLUTION
Avatar of ee_ai_construct
ee_ai_construct
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial