Crystal报表MVC4中的加载报表失败了吗?

时间:2016-05-19 07:42:16

标签: c# asp.net-mvc-4 crystal-reports

我为我的MVC4项目生成Crystal Report。如果我选择FromDate和ToDate取决于报告必须生成的日期。

加载报告时,它显示rc.Load()附近有一个错误。这个错误在下面提到。

CrystalDecisions.CrystalReports.Engine.dll中出现“CrystalDecisions.Shared.CrystalReportsException”类型的异常,但未在用户代码中处理

我的控制器代码

 public ActionResult VisitSummaryReport()

    {
        return View();
    }

    [HttpPost]

     public ActionResult GetDates(VisitorsViewModel VisitorsVM)
    {
        var fromdt = Convert.ToDateTime(VisitorsVM.FromDate);
        var todt = Convert.ToDateTime(VisitorsVM.ToDate);
        SqlConnection con = new SqlConnection(@"Data Source=192.168.0.73\SQLEXPRESS,14330;Initial Catalog=WafeERP_NEW;User ID=sa;Password=wafewin;");
        DataTable dt = new DataTable();
        try
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("Select * from View_VisitorsForm where  VisitingDate >='" + fromdt  +"'and VisitingDate <= '" + todt  +"'", con);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            adp.Fill(dt);

        }
        catch (Exception ex)
        {

            throw;
        }
        ReportClass rc = new ReportClass();
        rc.FileName = Server.MapPath("/Sales/Reports/rpt_VisitSummaryCrystalReport.rpt");
        rc.Load();
        rc.SetDataSource(dt);
        Stream stream = rc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        return File(stream, "application/pdf");
         }

1 个答案:

答案 0 :(得分:0)

或许将以下内容添加到您的web.config文件中会有所帮助:

<dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.CrystalReports.Engine" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportSource" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.Shared" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.Web" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.Windows.Forms" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.ClientDoc" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.CommonControls" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.CommonObjectModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.Controllers" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.CubeDefModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.DataDefModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.DataSetConversion" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.ObjectFactory" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.Prompting" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.ReportDefModel" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="CrystalDecisions.ReportAppServer.XmlSerialize" publicKeyToken="692fbea5521e1304" culture="neutral"/>
    <bindingRedirect oldVersion="13.0.3500.0" newVersion="13.0.2000.0"/>
  </dependentAssembly>

来源: CR for VS sp21 breaks Exact CR2013 Runtime - SAP Answer