cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports VS 2008 Object not found error

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

I believe the deployment of the CR runtime is the issue here. While creating your own MSM file is quite heroic , it is a futile attempt nevertheless. You must use the MSM or MSI files provided by SAP. Now, in all of this, the one piece of info that would help is missing; version of the CR assemblies referenced in the project. I could hazard a guess and go with 10.5.x, but that could lead us to more problems. E.g.; if you can let me know the version of the assemblies, we'll get things going from there.

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Hi Ludek,

Thanks for the quick response.

Crystal Reports Basic Runtime for Visual Studio 2008 is version 10.5.0.0

There are 7 CrystalDecision dlls in C:\Program Files\Business Objects\Common\2.8\Managed.  They are all version 10.5.0.1943

They are:

  1. CrystalDecisions.CrystalReports.Engine.dll
  2. CrystalDecisions.Data.AdoDotNetInterop.dll
  3. CrystalDecisions.ReportSource.dll
  4. CrystalDecisions.Shared.dll
  5. CrystalDecisions.VSDesigner.dll
  6. CrystalDecisions.Web.dll
  7. CrystalDecisions.Windows.Forms.dll

I downloaded a few MSM files from the web site but I am not that sure of how they are supposed to work.  I had at one time added them to a setup project in my solution but I didn't know (or had forgotton) that MSM files were setup files (I knew MSI files were setup files because I have used them a lot) so I didn't try running them on the web server.  I just assumed that creating a setup project would take care of everything for me.

I have downloaded these zip files

  • cr10_net_merge_modules
  • cr120_mm
  • cr2008sp4_mm
  • cr_net_2005_mm_mlb_x86

Should I have used one of those Merge Modules and if so how should I have done it?  It has far too many years since I have created an installation project and I have never used merge modules.

Thanks,

Robert

former_member183750
Active Contributor
0 Kudos

Have a look at this doc. It has the links to the correct runtime files.

- Ludek

Former Member
0 Kudos

Hi Ludek,

I might have been wrong about the whole problem.  I kept thinking that because the error message said that it could not create a reference to the object that it meant that there was a problem with the application trying to either find or open the Crystal Reports object.

I ran the crbasic2008sp1.exe program on the development web server that I download from the link you provided me and nothing changed.  I then downloaded CRRedist2008_x86.msi ran that on the development server and still nothing changed.

But a thought just popped up in my mind what if the folder where Crystal puts the PDF file doesn't have the correct permissions.  I saw that the Authenticated Users did not have write permission.  I changed that and the next thing I know there is a brand new PDF file in that folder and no error messages.

I tried this on the production machine but there is another problem that has nothing to do with Crystal Reports going on right now.  It seems that because the app uses MS Access if someone else is running the app it locks out all other users.  I could not even bring up the web page that has the button to create the PDF file.  It is very frustrating because I want to verify if the fix was just the network permissions or a combination of everything I did to the development server.

I will find out tomorrow, hopefully, because I get in before most of the other users and hopefully they will have closed the application and I can test for sure if I have a solution.

If I continue to have a problem on the production server I will contact you tomorrow but if what I have fixed the problem then I will thank you for your time and help.  I very much appreciate it.

Take care

Robert

Former Member
0 Kudos

The problem was a permissions issue.  I gave the folder that Crystal Reports writes to write permission on the production web server and life was wonderful again.

former_member183750
Active Contributor
0 Kudos

Happy it's working

These permissions are a pain - is all I can say...

Have a great weekend,

- Ludek

Answers (0)