我有方法,我正在使用晶体决策报告,并且抛出内部异常。如何解决此问题?我见过类似的话题,但是我的尝试并没有真正解决类似的问题。请在下面查看我的逻辑和屏幕截图,以获取更多详细信息。换句话说,我的加载方法无法打开。
// Controller
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult AdvertReport(FormCollection fc)
{
DataSet ds = obIlReports.Generate_AdvertDetailsReport();
ds.Tables[0].TableName = "Tbl_TrainingAcademy";
if(ds.Tables[0].Rows.Count > 0)
{
ReportClass rptH = new ReportClass();
rptH.FileName = Server.MapPath("~/Reports/AdvertReport.rpt");
rptH.Load(); // The document do not open error is thrown here.
rptH.SetDataSource(ds.Tables[0]);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "AdvertReport.pdf");
}
return View();
}
// Ilreport here with store procedure.
public class ReportsMaster : IlReports
{
public DataSet Generate_AdvertDetailsReport()
{
using(SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["eNtsaOnlineRegistrationDB"].ToString()))
{
con.Open();
DataSet ds = new DataSet();
// Handling Exception
try
{
SqlCommand cmd = new SqlCommand("dbo.GetAdvertReport", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
if(ds.Tables.Count > 0)
{
return ds;
}
else
{
return ds = null;
}
}
catch(Exception )
{
throw;
}
finally
{
ds.Dispose();
}
}
}
}
// ConnectionString
<connectionStrings>
<add name="eNtsaOnlineRegistrationDB" connectionString="Data Source=GcobaniM-L\SQLEXPRESS; DataBase=eNtsaOnlineRegistrationDB; Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
Could not load file or assembly CrystalDecisions.CrystalReports.Engine