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.
unable to evaluate expression because the code is optimized
Re: unable to evaluate expression because the code is optimi
Hello, Charles.
We need more information about your issue.
Could you send us a sample project which reproduces the issue?
Thank you.
We need more information about your issue.
Could you send us a sample project which reproduces the issue?
Thank you.
Re: unable to evaluate expression because the code is optimi
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);
}
}
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);
}
}
- Attachments
-
- FinancialPosition.dll.txt
- (24 KiB) Downloaded 160 times
Re: unable to evaluate expression because the code is optimi
Hello.
Sorry, but we could not reproduce the issue with this information.
Please, send us a working project with all necessary data.
Thank you.
Sorry, but we could not reproduce the issue with this information.
Please, send us a working project with all necessary data.
Thank you.