ExportToHttpResponse causeing error

I created a report with crystal reports.  I am using ExportToHttpResponse to open the report as an attachment.  

ReportDocument report = new ReportDocument();
reporty.Load(Server.MapPath(@"reports/myreport.rpt"));
report.SetDataSource(ds.Tables[0]);
report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, filename);

Open in new window


I was walking through the code and receive the below error.

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

The report does open but can't figure out why ExportToHttpResponse is having an error.

Any ideas?
LVL 1
CipherISAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
informaniacConnect With a Mentor Commented:
That error occurs whenever a dialog box gets opened and the code is in a try/catch.

Here since a file is getting opened as attachment it will give that error.
0
 
informaniacCommented:
Is the code inside a try catch? I guess ExportToHttpResponse  should not be inside a try block
0
 
CipherISAuthor Commented:
It is in a try/catch that is how I found out it is returning - "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."
0
All Courses

From novice to tech pro — start learning today.