Skip to Content
0
Former Member
Jun 23, 2015 at 04:41 PM

CR Viewer takes a while to load (Code Review)

50 Views

Hello -

Issue Background:

I've created an application that utilizes the CR Viewer. Sometimes it loads quickly, other times not so much. This morning I received a support ticket explaining that a report was coming back blank, and that it took 45 minutes to run!

I tested it on the web server (2012 R2 - Virtual) and sure thing it is taking forever to run. Tried running the app from localhost on my machine and it displayed within 5 minutes. Next, I ran the sql script (SQL Server 2012) and its taking the script 4 minutes to run (I didn't write it) - obviously this needs to be optimized!

Question:

Is there a setting I can set within the CR viewer so it doesn't timeout and return a blank document when run from the Web server? Why would the web version take so much longer to run - I've seen times from 18 minutes to 45 minutes.

Environment:

VS 2013 Professional

SQL Server 2012

Desktop Win 7

Web Server 2012 R2

Crystal Reports Developer V13

Crystal Reports Designer we have reports that are built using 2008 & XI

HTML Code:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Viewer.aspx.vb" Inherits="Unconfirmed.Viewer" %>

<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" EnableDatabaseLogonPrompt="False" HasCrystalLogo="False" Height="50px" Width="350px" />

</div>

</form>

</body>

</html>

Code Behind:

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Imports CrystalDecisions.Web

Imports Unconfirmed.Components.Framework

Public Class Viewer

Inherits System.Web.UI.Page

Private rptPath As String = ""

Private rptDoc As ReportDocument

Private strAuthUser As String = ""

Private _config As New Config

Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init

ConfigureCrystalReports()

End Sub

Private Sub ConfigureCrystalReports()

rptDoc = New ReportDocument

Try

rptPath = _config.ReportPath + Session("SelectedReport").ToString

rptDoc.Load(rptPath)

rptDoc.SetDatabaseLogon(_config.CrystalUser, _config.CrystalPassword)

CrystalReportViewer1.ReportSource = rptDoc

Catch ex As Exception

Response.Write("There has been an error processing the file at: " + rptPath + " || Exception Message: " + ex.Message.ToString + " || Exception Inner Message: " + ex.InnerException.ToString)

End Try

End Sub

Private Sub form1_Unload(sender As Object, e As EventArgs) Handles form1.Unload

Me.rptDoc.Close()

Me.rptDoc.Dispose()

End Sub

End Class