Skip to Content
0
Former Member
Jun 26, 2013 at 09:20 PM

Crystal Reports VS 2008 Object not found error

343 Views

I am trying to fix a problem in an application that was written by another developer who is no longer with the company. From the looks of it it never worked.

It was written in VB.net using VS 2005 or 2008 but I only have VS 2008 to debug it with so any changes I make will make it a 2008 application. When I run the code in VS on my local machine there is no problem at all. Life is wonderful.

When I compile it and publish to the web server (Windows Server 2003 SP2 & IIS 6) the command that actually prints the report or in my case creates a PDF file generates this ASP.Net error:

Server Error in '/MyApplication' Application.




Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.



Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

MyApplication.libMyAppFunctions.ExportAndDisplayPDF(Object objTemp) in H:\MyApplication\library\libMyAppFunctions.vb:499

MyApplication.Default.btnPrint_Click(Object sender, EventArgs e) in H:\MyApplication\Default.aspx.vb:1454

System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111

System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565






Version Information: Microsoft .NET Framework Version:2.0.50727.3643; ASP.NET Version:2.0.50727.3634

Here is the Visual Basic.Net code that is triggered from the Print Button.

Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Dim d
Dim objViewReport As ViewReport = New ViewReport(frmView)
dtReportComments = objViewReport.getDtReportComments

Dim oRpt As Object

If (objViewReport.intTimeOfDayID <> -1) Then
oRpt = New rptTOC_DateSpecific()
Else
oRpt = New rptTOC_DateAll()
End If
oRpt.SetDataSource(dtReportComments)

'set Season, date and TimeOfDay
Dim toSeason As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtSeason")
Dim toTitle As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtViewReportDate")
Dim toTimeOfDay As CrystalDecisions.CrystalReports.Engine.TextObject = oRpt.ReportDefinition.ReportObjects.Item("txtTimeOfDay")

toSeason.Text = objViewReport.strSeasonID

If (objViewReport.intTimeOfDayID <> -1) Then
toTitle.Text = objViewReport.datViewReportDate.ToString("MM/dd/yyyy")
toTimeOfDay.Text = objViewReport.strTimeOfDay
Else
toTitle.Text = "All"
toTimeOfDay.Text = "All"
End If

ExportAndDisplayPDF(oRpt)
End Sub

The ExportAndDisplayPDF(oRpt) function looks like this:

Public Function ExportAndDisplayPDF(ByVal objTemp As Object)
     Dim dNow As DateTime = Now

     Dim strFileName As String = dNow.Ticks & ".pdf"
     'write to a pdf file.
     Dim DiskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
     objTemp.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
     objTemp.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat

     DiskOpts.DiskFileName = HttpContext.Current.Request.PhysicalApplicationPath.ToString & "ReportOutput\" & strFileName

     objTemp.ExportOptions.DestinationOptions = DiskOpts
     Try
          objTemp.Export()
     Catch oRptExcept As Exception
          HttpContext.Current.Response.Write(oRptExcept.Message & "

" & oRptExcept.InnerException.Message) End Try HttpContext.Current.Response.Redirect("/MyApplication/aspx/print/Print.aspx?theDestination=" & strFileName) End Function

And the error is generated at the objTemp.Export() method call.

I have looked all over the internet for clues that might help. I found some information about adding a set up project to the VS solution and including a Merge Module file in that project. I tried that but it did not work. Then I tried taking the msm files out and adding in some dlls that are accessible to the project; CrystalDecisions.CrystalReports.Engine.dll, CrystalDecisions.ReportSource.dll, CrystalDecision.Shared.dll, CrystalDecisions,Web.dll.

I then compiled that project and copied the set up files to the development web server and a different error was displayed on the ASP.net error page.

Server Error in '/MyApplication' Application.




Retrieving the COM class factory for component with CLSID {5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error: 8007007e.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Retrieving the COM class factory for component with CLSID {5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error: 8007007e.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[FileNotFoundException: Retrieving the COM class factory for component with CLSID {5FF57840-5172-4482-9CA3-541C7878AE0F} failed due to the following error: 8007007e.]
CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor() +207

[TypeInitializationException: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.] CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor() +0
CrystalDecisions.CrystalReports.Engine.ReportClass..ctor() +18
MyApplication.MyReport..ctor() in H:\MyApplication\Reports\MyReport.vb:25
MyApplication.Default.btnPrint_Click(Object sender, EventArgs e) in H:\MyApplication\Default.aspx.vb:1445
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +111
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +79
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565



Version Information: Microsoft .NET Framework Version:2.0.50727.3643; ASP.NET Version:2.0.50727.3634

I copied the same setup files to the production web server and ran them but I still get the same error message that I have always gotten on the that server.

I should mention that on both the development and production servers Crystal Reports Basic Runtime for Visual Studio 2008 is installed and shows up in the Add or Remove Programs in the Control Panel. Since I ran my setup files which I called CrystalSetup also appears in Add or Remove Programs.

And when the CrystalSetup app asked for the web site and application pool I pointed them to my web site and my application.

The data the application is trying to display in the PDF is being retrieved from an Access 2007 database.

That's all I can think of to hopefully help get this problem resolved, If I haven't given enough information please let me know.

Thanks

Robert