本文介绍了Log4net的Crystal Report错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经使用Visual Studio 2010开发了网站,并附带了水晶报表13.0.2000.0.在本地,它工作正常,没有任何错误.当我在共享主机中发布网站以及dll的文件时,出现如下错误.

错误System.TypeInitializationException:"CrystalDecisions.CrystalReports.Engine.ReportDocument"的类型初始值设定项引发了异常. ---> CrystalDecisions.CrystalReports.Engine.LoadSaveReportException:尝试加载Crystal Reports运行时时发生错误. Crystal Reports注册表项权限不足或未正确安装Crystal Reports运行时.请安装适当的Crystal Reports可再发行文件(CRRedist * .msi),其中包含所需的正确版本的Crystal Reports运行时(x86,x64或Itanium).

我为此使用了以下代码.

Hi,

I have developed website using visual studio 2010 with crystal report 13.0.2000.0. and locally it is working fine without any error. When i published website in shared hosting along with dll''s files it is giving an error as follows.

Error System.TypeInitializationException: The type initializer for ''CrystalDecisions.CrystalReports.Engine.ReportDocument'' threw an exception. ---> CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: An error has occurred while attempting to load the Crystal Reports runtime. Either the Crystal Reports registry key permissions are insufficient or the Crystal Reports runtime is not installed correctly. Please install the appropriate Crystal Reports redistributable (CRRedist*.msi) containing the correct version of the Crystal Reports runtime (x86, x64, or Itanium) required.

i have used following code for this.

protected void lnkprintResult_Click(object sender, EventArgs e)
    {
        string sSql = "";
        
            
            sSql = "select subjects.Subject_Name as str1,exam_log.max_marks as float1,exam_log.mini_marks as float2,exam_score.obtained_marks as float3,exam_score.is_pass as float4 from subjects as subjects , exam_score as exam_score,Exam_log as Exam_log,student_subject as student_subject";
            sSql = sSql + " where student_subject.subject_id=exam_score.subject_Id and exam_log.exam_id=exam_score.exam_Id and student_subject.subject_id=exam_log.subject_Id and exam_score.student_id=student_subject.student_Id and exam_score.subject_id=subjects.subject_Id and exam_score.Exam_Id=2 and exam_score.student_id=99";
            
            try
            {
                DSGeneral oRpt = new DSGeneral();
                SqlConnection myConnection = new SqlConnection();
                myConnection.ConnectionString = "My ConnectionString";
                SqlCommand MyCommand = new SqlCommand();
                MyCommand.Connection = myConnection;
                MyCommand.CommandText = sSql;
                MyCommand.CommandType = CommandType.Text;
                SqlDataAdapter MyDA = new SqlDataAdapter();
                MyDA.SelectCommand = MyCommand;               
                DataTable dt = new DataTable();
                MyDA.Fill(oRpt, "datatable1");
                dt = oRpt.Tables[0];

                string fileName = Server.MapPath("~/Pages/CollegeAdmin/Reports/RptExamResult.rpt");
                ReportDocument doc = new ReportDocument();
                
                doc.Load(fileName);
                doc.SetDataSource(dt);

                doc.SetParameterValue("ExamName", lblExamName.Text);
                doc.SetParameterValue("studentRegNo", lblStudentRegno.Text);
                doc.SetParameterValue("StudentName", lblStudent_Name.Text);
                doc.SetParameterValue("Course", lblCourseName.Text);
                doc.SetParameterValue("Batch", lblBatchName.Text);

               
                ExportOptions rptExprt;
                DiskFileDestinationOptions dir = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions rpt = new PdfRtfWordFormatOptions();

                dir.DiskFileName = Server.MapPath("~/temp.pdf");
                rptExprt = doc.ExportOptions;
                rptExprt.ExportDestinationType = ExportDestinationType.DiskFile;
                rptExprt.ExportFormatType = ExportFormatType.PortableDocFormat;
                rptExprt.ExportDestinationOptions = dir;
                rptExprt.ExportFormatOptions = rpt;
                doc.ToString();
                doc.Export();
                //doc.Refresh();
                doc.Close();
                //generaterpt();
               
                this.Page.RegisterStartupScript("ViewPDF", <Script>window.open('../../temp.pdf','_blank') </script>");
            }
            catch (Exception exc)
            {
                lblMsg.Text = "Error " + exc;
            }
        } 



请指导我如何解决此问题.

问候

Parashuram.



Please guide me how should i solve this issue.

Regards

Parashuram.

推荐答案


这篇关于Log4net的Crystal Report错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 20:36