Crystal Report Errors

manared

Well-known member
Joined
Jun 1, 2006
Messages
84
Programming Experience
1-3
I'm using Visual Studio 2008 and i'm trying to create a report using Crystal Reports. I've created a report using Crystal Reports product version 11.5.0.313. Here's my asp code:

HTML:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
            AutoDataBind="true" />
    
    </div>
    </form>
</body>
</html>

Here's my vb code:
VB.NET:
Imports CrystalDecisions.Web
Imports CrystalDecisions.CrystalReports.Engine


Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        BuildReport()
    End Sub

    Private Rep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    Private Sub BuildReport()

        Dim dt As Data.DataTable
        Dim DBObj As New JobMastModel.DBClasses.DBTools
        Dim project As String = "True"
        'create datatable, then load into report viewer
        dt = DBObj.CreateDT("Select * from tblTaskListTasks where project = '" & project & "'", JobMastModel.DBClasses.DBTools.DB.DW)


        Rep.Load("C:\Inetpub\Programs\Reports\TaskProjects.rpt")
        Rep.SetDataSource(dt)
        CrystalReportViewer1.ReportSource = Rep
        CrystalReportViewer1.DataBind()
        'ReportTool.ReportColors(Rep)

    End Sub



    Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        Rep.Close()
        Rep.Dispose()
    End Sub
End Class

And here's my web.config file
HTML:
<?xml version="1.0"?>

<configuration>
	
	<appSettings>
		<add key="CrystalImageCleaner-AutoStart" value="true"/>
		<add key="CrystalImageCleaner-Sleep" value="60000"/>
		<add key="CrystalImageCleaner-Age" value="120000"/>
	</appSettings>
	<connectionStrings/>
	<system.web>
			<compilation debug="true" strict="false" explicit="true">
			<assemblies>
				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
				<add assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
				<add assembly="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
				<add assembly="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
				<add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/><add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Enterprise.Framework, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></assemblies>
		</compilation>
		<pages>
			<namespaces>
				<clear/>
				<add namespace="System"/>
				<add namespace="System.Collections"/>
				<add namespace="System.Collections.Generic"/>
				<add namespace="System.Collections.Specialized"/>
				<add namespace="System.Configuration"/>
				<add namespace="System.Text"/>
				<add namespace="System.Text.RegularExpressions"/>
				<add namespace="System.Linq"/>
				<add namespace="System.Xml.Linq"/>
				<add namespace="System.Web"/>
				<add namespace="System.Web.Caching"/>
				<add namespace="System.Web.SessionState"/>
				<add namespace="System.Web.Security"/>
				<add namespace="System.Web.Profile"/>
				<add namespace="System.Web.UI"/>
				<add namespace="System.Web.UI.WebControls"/>
				<add namespace="System.Web.UI.WebControls.WebParts"/>
				<add namespace="System.Web.UI.HtmlControls"/>
			</namespaces>
			
		</pages>

		<authentication mode="Windows"/>

		<httpHandlers>
			<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></httpHandlers>
		
	</system.web>

	<system.webServer>
		
		<handlers>
			
			<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/></handlers>
		<validation validateIntegratedModeConfiguration="false"/>
	</system.webServer>
	
</configuration>

When I run the page I get this error:
Could not load file or assembly 'System.Web.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

In my other web applications I've already created, I've been trying to get Crystal reports to work too and i keep getting errors. One error I get with my other programs is that the control (Report Viewer) errored. "Cannot Create Control" and another error i'm getting is that "Report Document" is ambiguous in the namespace. Does anyone know how to fix any of these issues? I'm pretty sure i'm referencing only one version of crystal.
Thank you!
 
You need to add Crystal to the references of the project.
Having them referenced means you shouldn't have to IMPORT anything. I got various CR viewers, reports and what not flying around on forms (albeit winforms) and I've not got one IMPORT statement for Crystal.

I think there should be about 6 references needed, each called CrystalDecisions.XYZ where XYZ is the name of the ref.

It should add these when you drag a CR viewer to your app, check to see if you have these. Also check their versions in case they don't match that of what version of CR you have installed.
 
Back
Top