unable to evaluate expression because the code is optimized

Stimulsoft Reports.WEB discussion
Post Reply
Charles
Posts: 4
Joined: Tue Mar 24, 2015 8:14 am

unable to evaluate expression because the code is optimized

Post by Charles »

Dear,

I am using the below methods and all are throwing the exception "unable to evaluate expression because the code is optimized or a native frame is on top of the call stack":

1. StiReportResponse.ResponseAsXls(this.Page, rptReport, stiExcelSettings);
2. StiReportResponse.ResponseAsPdf(this.Page, rptReport, true, stiPdfSettings);
3. StiReportResponse.ResponseAsHtml(this.Page, rptReport, true, settings, null);

I tried using rptReport.ExportDocument(StiExportFormat.Pdf, "file") but I am referencing the Report as a dll and not using the .mrt file and i don't need to save the report in a specific location, I only need to open the report in Excel, PDF, or HTML.

What would be the solution for this issue?

Thank you
Charles.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: unable to evaluate expression because the code is optimi

Post by HighAley »

Hello, Charles.

We need more information about your issue.
Could you send us a sample project which reproduces the issue?

Thank you.
Charles
Posts: 4
Joined: Tue Mar 24, 2015 8:14 am

Re: unable to evaluate expression because the code is optimi

Post by Charles »

Dear,

Please find below the full ExportTo Excel event code in addition to the attached mrt file:

protected void btnExportToExcel_Click(object sender, EventArgs e)
{
try
{
string strId = hdCustomerId.Value;
string strNumber = hdAccountNumber.Value;
string strEntityAttribute = string.Empty;
string strAttributeValue = string.Empty;
if (!string.IsNullOrEmpty(strId))
{
strEntityAttribute = "CustomerID";
strAttributeValue = strId;
}
else
{
strEntityAttribute = "AccountNumber";
strAttributeValue = strNumber;
}
DataTable dttAllAccounts = RetrieveAllAccounts(strEntityAttribute, strAttributeValue);
FinancialPosition rptFinancialPosition = new FinancialPosition();
rptFinancialPosition.ReportName = "FinancialPosition (" + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-sss") + ")";
rptFinancialPosition.Image1.Image = Image.FromFile(ConfigurationManager.AppSettings["LogoURL"].ToString());
rptFinancialPosition.CustomerId = strId;
rptFinancialPosition.CustomerName = strCustomerName.ToUpper();
rptFinancialPosition.DataSources[0].DataTable = dttAllAccounts;

StiExcelExportSettings stiExcelSettings = new StiExcelExportSettings();
rptFinancialPosition.Render();
StiReportResponse.ResponseAsXls(this.Page, rptFinancialPosition, stiExcelSettings);
}
catch (Exception ex)
{
ExceptionHandler.LogException(ex);
}
}
FinancialPosition.mrt
(22.15 KiB) Downloaded 248 times
Attachments
FinancialPosition.dll.txt
(24 KiB) Downloaded 160 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: unable to evaluate expression because the code is optimi

Post by HighAley »

Hello.

Sorry, but we could not reproduce the issue with this information.
Please, send us a working project with all necessary data.

Thank you.
Post Reply