简体   繁体   中英

Load report failed in Crystal report MVC4?

Hi i generate Crystal Report for my MVC4 project. if i select the FromDate and ToDate depend upon the dates the report have to generate.

While loading report it showing one error near to rc.Load(). That error is mention below.

An exception of type 'CrystalDecisions.Shared.CrystalReportsException' occurred in CrystalDecisions.CrystalReports.Engine.dll but was not handled in user code

My Controller Code

 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");
         }

Perhaps adding the following to your web.config file would help:

<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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM