Я строю приложение для Windows с локальным отчет с помощью RDLC, он хорошо работает, когда я запускаю код внутри VS2012, но когда я развернуть приложение дает мне некоторые ошибки:RDLC Local Report после скрыт развернуть не работает
Ошибка при обработке локального отчета.
Определение отчета для отчета «Report1.rdlc» был не указан
Не удалось найти часть пути «C: ... \ Report1.rdlc».
Код им с помощью:
DataSet2 ds = new DataSet2();
DataTable dt = ds.Table2;
DataRow dr = null;
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
dr = ds.Table2.NewRow();
dr["Nr"] = dataGridView1.Rows[i].Cells[0].Value.ToString();
dr["Ary"] = dataGridView1.Rows[i].Cells[1].Value.ToString();
dr["Car"] = dataGridView1.Rows[i].Cells[2].Value.ToString();
dr["Total"] = dataGridView1.Rows[i].Cells[3].Value.ToString();
dr["Total2"] = dataGridView1.Rows[i].Cells[4].Value.ToString();
// MessageBox.Show(dr["Vetura"].ToString());
ds.Table2.Rows.Add(dr);
dt.AcceptChanges();
}
dr.AcceptChanges();
string exeFolder = (Path.GetDirectoryName(Application.StartupPath)).Substring(0, (Path.GetDirectoryName(Application.StartupPath)).Length - 3);
string reportPath = Path.Combine(exeFolder, @"Report1.rdlc");
//MessageBox.Show(reportPath.ToString());
Microsoft.Reporting.WinForms.ReportDataSource rds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet2", ds.Tables[0]);
ra.reportViewer1.LocalReport.DataSources.Clear();
ra.reportViewer1.LocalReport.DataSources.Add(rds);
ra.reportViewer1.LocalReport.ReportPath = reportPath;
if (textBox2.TextLength > 0)
{
ReportParameter Percentage = new Microsoft.Reporting.WinForms.ReportParameter("Percentage", "-" + textBox2.Text + "%");
ReportParameter Total = new Microsoft.Reporting.WinForms.ReportParameter("Total", textBox3.Text);
ra.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Percentage });
ra.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Total });
}
//HERE IS THE FIRST ERROR , WHEN I PASS THE THE TEXT TO THE PARAMETER
ReportParameter Klienti = new Microsoft.Reporting.WinForms.ReportParameter("Klienti", textBox1.Text);
ra.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Klienti });
ra.reportViewer1.RefreshReport();
Можете ли вы попробовать установить рабочий каталог в exefolder и посмотреть, помогает ли это? Просто откройте командную строку, смените каталог на папку exe и запустите exe –
@GaneshR. я не совсем понял вас, что вы имеете в виду, устанавливая рабочий каталог в exefolder? – user3334406
Предположим, что ваш exe находится в C: \ Data, откройте командную строку и введите cd/d C: \ Data. Затем просто введите имя exe и нажмите enter. В основном ваш рабочий каталог приложений был установлен в c: \ Data –