Crystal report method not found

15,987

This isn't a coding issue, it's a runtime issue. The version of the crystal runtime or the bitness of your application.

One thing to try first is to upgrade both your development version and ensure you're running the same version in production. See https://apps.support.sap.com/sap/support/knowledge/public/en/2148492 for more details

It says:

Compile your application either to 'X86 mode' or 'X64 mode' Install the particular versions of runtimes on deployment machine.

i.e. If the application is compiled as 32 bit, then install the 32bit runtimes.

Share:
15,987
Wasif Bhatti
Author by

Wasif Bhatti

Updated on June 04, 2022

Comments

  • Wasif Bhatti
    Wasif Bhatti almost 2 years

    I made a feedback project. I made it on ASP.NET MVC 5 it also has crystal reports. reports were working fine, but suddenly they stopped to work. I don't what happened with them. but since last week I tried hard to find solution but unfortunately could not get the right one who solved the solution. I downloaded different run times but all went vain. this is the bottom line of error.

    "Method not found: 'CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag CrystalDecisions.ReportAppServer.ReportDefModel.ISCRExportOptions.get_ExportOptionsEx()'" this is the code:

    public CrystalReportFeedback UserFeedbackDateWise(FeedbackReport be){

            if (Session["CurrentUser"] != null && Convert.ToInt32(Session["User_Id"]) != 0)
            {
                string reportPath = Path.Combine(Server.MapPath("~/Reports"), "UserFeedbackReport.rpt");
                if (ModelState.IsValid)
                {
                    be.FromDate = Convert.ToDateTime(TempData["UserFromDate"]);
                    be.ToDate = Convert.ToDateTime(TempData["UserToDate"]);
                    be.User_Id = Convert.ToInt32(Session["User_Id"]);
                }
                return new CrystalReportFeedback(reportPath, be);
            }
            else
            {
                return null;
                //new CrystalReportFeedback(reportPath, be);
            }
        }
    

    Init of the report :

    public CrystalReportFeedback(string reportPath, FeedbackReport be)//, object dataSet)
            {
                //int[] array;
                string strConnect = Convert.ToString(System.Configuration.ConfigurationManager.ConnectionStrings["TSC"]);
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(strConnect);
                string _username = builder.UserID;
                string _pass = builder.Password;
                string _server = builder.DataSource;
                string _database = builder.InitialCatalog;
                ReportDocument reportDocument = new ReportDocument();
                //
                reportDocument.Load(reportPath);
                reportDocument.SetDatabaseLogon(_username, _pass, _server, _database);
                if (be.Region_Id != 0)
                {
                    reportDocument.SetParameterValue("@Region_Id", be.Region_Id);
                }
                if (be.User_Id != 0)
                {
                    reportDocument.SetParameterValue("@User_Id", be.User_Id);
                }
                reportDocument.SetParameterValue("@FromDate", be.FromDate);
                reportDocument.SetParameterValue("@ToDate", be.ToDate);
                //reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, "C:\report.pdf");
                _contentBytes = StreamToBytes(reportDocument.ExportToStream(ExportFormatType.PortableDocFormat));
            }
    

    Export method :

        public override void ExecuteResult(ControllerContext context)
        {
    
            var response = context.HttpContext.ApplicationInstance.Response;
            response.Clear();
            response.Buffer = false;
            response.ClearContent();
            response.ClearHeaders();
            response.Cache.SetCacheability(HttpCacheability.Public);
            response.ContentType = "application/pdf";
    
            using (var stream = new MemoryStream(_contentBytes))
            {
                stream.WriteTo(response.OutputStream);
                stream.Flush();
            }
        }
    
        private static byte[] StreamToBytes(Stream input)
        {
            byte[] buffer = new byte[16 * 1024];
            using (MemoryStream ms = new MemoryStream())
            {
                int read;
                while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
                {
                    ms.Write(buffer, 0, read);
                }
                return ms.ToArray();
            }
        }
    

    Hope that I will get my solution at earliest.

    this is modified code:

    [HttpGet]

        public FileResult UserFeedbackDateWise(FeedbackReport be)
        {
    
            if (Session["CurrentUser"] != null && Convert.ToInt32(Session["User_Id"]) != 0)
            {
                string reportPath = Path.Combine(Server.MapPath("~/Reports"), "UserFeedbackReport.rpt");
                if (ModelState.IsValid)
                {
    
                    be.FromDate = Convert.ToDateTime(TempData["UserFromDate"]);
                    be.ToDate = Convert.ToDateTime(TempData["UserToDate"]);
                    be.User_Id = Convert.ToInt32(Session["User_Id"]);
                }
                string strConnect = Convert.ToString(System.Configuration.ConfigurationManager.ConnectionStrings["TSC"]);
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(strConnect);
                string _username = builder.UserID;
                string _pass = builder.Password;
                string _server = builder.DataSource;
                string _database = builder.InitialCatalog;
                ReportDocument reportDocument = new ReportDocument();
                //
                reportDocument.Load(reportPath);
                reportDocument.SetDatabaseLogon(_username, _pass, _server, _database);
                if (be.Region_Id != 0)
                {
                    reportDocument.SetParameterValue("@Region_Id", be.Region_Id);
                }
                if (be.User_Id != 0)
                {
                    reportDocument.SetParameterValue("@User_Id", be.User_Id);
                }
                reportDocument.SetParameterValue("@FromDate", be.FromDate);
                reportDocument.SetParameterValue("@ToDate", be.ToDate);
    
                Stream stream = reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
    
                //Here i have my stream with my pdf report, i just create a new FileStreamResult and return it to my client like that : 
                FileStreamResult myfile = new FileStreamResult(stream, "application/pdf");
                return myfile;
                    //new CrystalReportFeedback(reportPath, be);
            }
            else
            {
                return null;
                //new CrystalReportFeedback(reportPath, be);
            }
        }
    
  • Wasif Bhatti
    Wasif Bhatti over 7 years
    Mr.@Furtiro :'(
  • Furtiro
    Furtiro over 7 years
    Which line cause this error ? I edited my answer with useful links, if working code don't work that could be a Crystalreport installation or runtime error ( or maybe config error )
  • Wasif Bhatti
    Wasif Bhatti over 7 years
    Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType‌​.PortableDocFormat); this line displaying error
  • Wasif Bhatti
    Wasif Bhatti over 7 years
    do you know how can i check the version of visual studio 2013? because this is my official laptop and everything was already installed in this laptop. can you plz guide me
  • reckface
    reckface over 7 years
    It's the version of crystal you need to upgrade. Check in the web.config file to determine what version your application is running. You want to be in the 13.x range, and watch the support pack version. You can download them from: blogs.sap.com/2016/12/06/…
  • Wasif Bhatti
    Wasif Bhatti over 7 years
    yes resolved. there was version problem. Thanx alot :)