• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 881
  • Last Modified:

Crystal Reports - Load Report Failed error

VS Studio 2005 Professional
Windows Forms

I am in the process of releasing an application for sale.  I have created the setup files for the application with prerequisites included.  I followed the BusinessObjects instructions on adding a merge module into my setup.  Very straightforward.  I added the file 'CrystalReportsRedist2005_x86.msm' which in turn added the files 'Microsoft_VC80_ATL_x86.msm' & 'policy_8_0_Microsoft_VC80_ATL_x86.msm' under Dependencies.  I have executed the program where I am using the following:

VB 2005
SQL Server 2005 Express
Crystal Reports for VB 2005

I ran the setup.exe where it installed all of the above and am able to perform all functions I want within my app except running a CR report.  I'm getting the error below about not being able to find a file.  I have embedded CR reports in the application.  I originally had a path included as shown below where I've commented it out but I took it out prior to re-building my executable.

Error I received........
System.Exception: Load report failed. ---> System.Runtime.InteropServices.COMException (0x80004005): The system cannot find the file specified.


Imports CrystalDecisions.CrystalReports.Engine

Public Class ReportView
    Private Sub ReportView_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim docReport As New ReportDocument
        '' Commented !!       docReport.Load(glRootDirectory & glReportName)
        docReport.Load(glReportName)
        docReport.SetDataSource(dtReport)
        CrystalReportViewer1.ReportSource = docReport
    End Sub
    Private Sub Form_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        CloseForm()
        glReportName = ""
    End Sub
End Class


I am completely oblivious to the problem.  And to make it worse I was going to install my program today at a customer site.

Please help...Thanks!
Phil Tate
0
TSFLLC
Asked:
TSFLLC
  • 6
  • 4
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
Hi TSFLLC,

> I have embedded CR reports in the application.

You cannot use the Load method with an embedded report. The Load method can only be used when you ship .rpt files with your application.

You need to change:
Dim docReport As New ReportDocument

For:
Dim docReport As New YourReportName


Cheers!
0
 
TSFLLCAuthor Commented:
Eric,

Dim docReport as New WHAT = YourReportName  ?

Phil
0
 
Éric MoreauSenior .Net ConsultantCommented:
Your report as a name when you look at it in the solution explorer. This name is also the name the report class. You need to use this name to create an instance of it.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
TSFLLCAuthor Commented:
I just found a BusinessObjects file on this as you were posting your next post.  I understand what you are doing now.

If you notice in my first post, I have a global variable that contains the file name.  Do I have to create a Case statement with all of my reports and set a Dim docReport as .... for each of them or is there a way to continue using glReportName where this would not be necessary.  I realize that glReportName has been populated with 'ReportName.rpt' and would need to be Changed to 'ReportName()'...or something like that.  Needless to say 'Dim docReport as New glReportName gives me a 'type not found' error.

Is this possible?
0
 
Éric MoreauSenior .Net ConsultantCommented:
>>Do I have to create a Case statement with all of my reports and set a Dim docReport as .... for each of them

Yes.

Personnaly, I prefer to distribute the reports as external file. This way, I can modify any report, redistribute it without having to recompile the application.
0
 
TSFLLCAuthor Commented:
That was going to be my next question.....distribute them or not?     OK!

And if I do distribute them, I don't have to change anything in my original code?  Just make sure that my docReport.Load points to the appropriate path of the reports?

0
 
Éric MoreauSenior .Net ConsultantCommented:
Nothing to change. You keep your Load method and your variable.
0
 
TSFLLCAuthor Commented:
I just tested it and it worked.

Last question, and I think I know the answer but it will be easier to ask before testing.

In terms of the inclusion of reports, I just create a folder under my Setup project and add all of the reports into that Setup project folder.  When I perform the setup of the application, it will create the 'Reports' folder with all of the reports I included in the Setup project?


An eighteen month project finished!!! Time to make some money now.

Thanks for everything Eric.

Phil
0
 
Éric MoreauSenior .Net ConsultantCommented:
>>When I perform the setup of the application, it will create the 'Reports' folder with all of the reports I included in the Setup project?

It should.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now