Log4net的Crystal Report错误 [英] Crystal report error for log4net

查看:86
本文介绍了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.

推荐答案

您的错误消息是不言自明的.它说您没有在服务器上正确安装Crystal Reports.由于这是一个共享的托管环境,因此不太可能在服务器上安装Crystal Reports MSI.但是,您可以尝试对与Crystal Reports相关的dll文件进行bin部署.这篇博客文章应该可以帮助您做到这一点:

http://aspadvice.com/blogs/rjdudley/archive/2005/05/22/2597.aspx [ ^ ]

另外,请与您的托管服务提供商联系.由于它们托管ASP.NET网站,因此它们可能在服务器上安装了Crystal Reports运行时的版本.如果是这样,请找出版本,然后在您的开发计算机上进行匹配.然后,您可以像平常一样进行部署,并且应该都能正常工作.
Your error message is fairly self-explanatory. It says that you don''t have Crystal Reports properly installed on the server. Since this is a shared hosting environment, it is unlikely that you will get the Crystal Reports MSI installed on the server. However, you might try doing a bin deploy of the dll files associated with Crystal Reports. This blog post should help you to do so:

http://aspadvice.com/blogs/rjdudley/archive/2005/05/22/2597.aspx[^]

Also, check with your hosting provider. Since they are hosting ASP.NET sites, they might have a version of the Crystal Reports runtime installed on the server. If so, find out what the version is and then match that on your development machine. Then you can deploy like normal and it should all work.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆