Cannot instantiate crystal report in VS 2005 code

I recently installed VS 2005. I am able to create Crystal reports without a problem, and to run them and view them in the CrystalReportViewer. But I cannot instantiate the reports in order to manipulate them at runtime.

For example, I have a report called CRTest.rpt which shows perfectly in the viewer. I put the following line of code in a form's code-behind document, and the intellisense gives me a "Type 'CRTest' is not defined" error: Dim rpt as new CRTest

(I also tried 'Dim rpt as new CRTest.rpt').

I think I have all the Crystal Report references set. I am able to maninpulate the object methods and properties of the viewer, but just can't get at the report itself.

Any help greatly appreciated.



Answer this question

Cannot instantiate crystal report in VS 2005 code

  • ye_xiyong

    How I cannot get a handle on ReportDocument anywhere within the web project I'd like to be able to set text fields, etc, dynamically at run-time and it doesn't appear that it's possible.
  • Paul44

    If this is a web app, you are not able to instantiate reports like that. To do this you need to work with the Report Document class.

    Dim myReport As new ReportDocument
    myReport.Load(Server.MapPath("CRTest.rpt"))


  • MahendraB

    No, that's not what I said. I said you had to instantiate a ReportDocument variable which can be manipulated the same way as before. The other way was basically a wrapper around this class. It only ever really made sense for window applications as it allowed you not to have to ship the .rpt files with the exe, and that is why they removed it from web applications.
  • Jeffy

    So it is not possible to programmatically manipulate a report at run-time if it is going to be displayed on the web
  • Cannot instantiate crystal report in VS 2005 code