cancel
Showing results for 
Search instead for 
Did you mean: 

Crystalreportviewer error when trying to display report

informatica52
Discoverer
0 Kudos

Hello,

Currently I'm trying to display a report inside a winforms, I search many tutorial trying to see how should I made it and I came up with this:

I need a form whit a Crystalreportviewer on it, ok so I create it, and when I try to see if display correctly the report there is an exception that I dont know how to solve it.

Here is the code of my form as you can see there is a function call LanzadorReports which recibe a report and parameter list and pass the report to the crystalreportviewer, is very simple as you can see:

And the error happens on the first line of crystalreportviewer:

Is like if the crystal report viewer is not instantiated but is incrustated in the form so the error have no sense, could anyone help me?

DellSC
Active Contributor
0 Kudos

I changed the tag on your question because the question is about working with the .NET SDK. The "SAP Crystal Reports" tag is for questions about report design.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

First, set Copy local to False.

Leave Interopt to false also.

You are using SP 30, mark this page and keep it in your Favorite list:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

You are not setting the Viewers Report object to the report.

I my main test app I have a flag that if I use RAS to modify the report I set it, otherwise I use the Report Object:

try
{
    if (IsRpt)
    {
        crystalReportViewer1.ReportSource = rptClientDoc.ReportSource;
    }
    else
    {
        crystalReportViewer1.ReportSource = rpt;
    }
}
catch (Exception ex)
{
    btnSQLStatement.Text = "ERROR: " + ex.Message;
}

See if that works...

Don

Answers (2)

Answers (2)

informatica52
Discoverer
0 Kudos

Oh sorry I didnt see that line, It was a try that I made before a I wrote the post forget that line, lets pretend that doesnt exits.

But I check the properties of crystal reports references and Embed Interop Types is on false

And here is the proof that the crystalreportviewer is on the form:

DellSC
Active Contributor
0 Kudos

This line in your code makes me suspect that the CrystalReportViewer is not embedded in the form when the form is created:

Controls.Add(crystalReportViewer1);

So, you would have to either instantiate it at the top of the procedure or add it to the form so that it gets instantiated with the form. Also, on the CrystalDecisions references in your project, make sure that the "EmbedInteropTypes" property is set to False.

-Dell