Solved

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

Posted on 2004-10-24
6,368 Views
Last Modified: 2008-01-09
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
0
Question by:M0m0nga
    6 Comments
     
    LVL 100

    Expert Comment

    by:mlmcc
    Post your code.

    mlmcc
    0
     
    LVL 1

    Author Comment

    by:M0m0nga
    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
    0
     
    LVL 100

    Expert Comment

    by:mlmcc
    0
     
    LVL 42

    Expert Comment

    by:frodoman
    listening
    0
     
    LVL 1

    Author Comment

    by:M0m0nga
    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).
    0
     

    Accepted Solution

    by:
    Question answered by asker or dialog valuable.
    Closed, 500 points refunded.
    ee_ai_construct (replacement part #xm34)
    Community Support Admin
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now