Deepak Kataria

Deepak Kataria

  • NA
  • 5
  • 1.8k

Error while exporting crystal report into pdf.

Jun 12 2013 4:19 AM
Hi Everybody,

I am getting error in line "rDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Page.Response, true, "Job-" + abc);" as "unable to evaluate expression because the code is optimized or a native frame is on top of the call" while exporting report into pdf. Kindly see below code which i am using.

ReportDocument rDoc = new ReportDocument();
try
{


rDoc.Load(Server.MapPath("JobCard.rpt"));
rDoc.SetDatabaseLogon("sa", "Password", "ServerName", "Database");
rDoc.Refresh();
rDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Page.Response, true, "Job-" + abc);
rDoc.Close();
rDoc.Dispose();
GC.Collect();
Response.Redirect("SomePage.aspx", false);
}
catch (System.Threading.ThreadAbortException lException)
{
rDoc.ReportOptions.Dispose();
rDoc.Close();
rDoc.Dispose();
Response.Redirect("SomePage.aspx", false);
}


Thanking in advance.