Quantcast
Channel: Crystal Reports
Viewing all articles
Browse latest Browse all 1507

GoDaddy.com Error - The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.

$
0
0

Hello all,

I am getting the above error when trying to create the report.  It is when it does the "crChecklist = New ReportDocument" statement.  Here is my code below:

Protected Sub cmdSendEmail_Click(sender As Object, e As System.EventArgs) Handles cmdSendEmail.Click
        Dim crChecklist As ReportDocument
        Dim strReportName As String
        Dim myTable As DataTable
        'Save as PDF
        Dim CrExportOptions As ExportOptions
        Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
        Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()

        lblMsg.Text = Nothing
        lblMsg.Visible = False

        myTable = CType(Session("myDatatable"), DataTable)

        If myTable.Rows.Count = 0 Then
            lblMsg.Text = "You need to have entered at least one task before you can send an email"
            lblMsg.Visible = True
            Exit Sub
        End If

        strReportName = Server.MapPath("Reports\") & Replace(txtName.Text, " ", "_") & ".pdf"
        lblChecklistRptName.Text = strReportName

        Try
            crChecklist = New ReportDocument
            crChecklist.Load(Server.MapPath("crChecklist.rpt"))
            crChecklist.SetDataSource(myTable)

            crChecklist.SetParameterValue("pUserName", txtName.Text)
            crChecklist.SetParameterValue("pUserPicture", lblPictureFileName.Text)
            crChecklist.SetParameterValue("pLogo", "Images/BPTexas_Logo.png")

            CrDiskFileDestinationOptions.DiskFileName = strReportName
            CrExportOptions = crChecklist.ExportOptions
            With CrExportOptions
                '// Set the destination to a disk file
                .ExportDestinationType = ExportDestinationType.DiskFile
                '// Set the format to PDF
                .ExportFormatType = ExportFormatType.PortableDocFormat
                '// Set the destination options to DiskFileDestinationOptions object
                .DestinationOptions = CrDiskFileDestinationOptions
                .FormatOptions = CrFormatTypeOptions
            End With

            '// Export the report
            crChecklist.Export()
        Catch err As Exception
            lblMsg.Text = err.Message
            lblMsg.Visible = True
            Exit Sub
        End Try

        crChecklist.Close()
        crChecklist.Dispose()

        'Send Email
        Dim SMTP_User As String
        Dim SMTP_pass As String
        Dim SMTP_server As String
        Dim SMTP_Port As String
        Dim SMTP_SSL As Boolean

        SMTP_User = AppSettings("SMTP_User")
        SMTP_pass = AppSettings("SMTP_Password")
        SMTP_server = AppSettings("SMTP_server")
        SMTP_Port = AppSettings("SMTP_Port")
        If AppSettings("EnableSsl") = "True" Then
            SMTP_SSL = True
        Else
            SMTP_SSL = False
        End If

        Dim client As New SmtpClient

        Dim [from] As New MailAddress(AppSettings("noreply_email"))
        Dim [to] As New MailAddress(AppSettings("EmailInfo"))
        Dim message As New MailMessage([from], [to])

        message.Subject = "Checklist For " & txtName.Text
        message.Body = "Here is the checklist for " & txtName.Text
        message.IsBodyHtml = False
        message.Attachments.Add(New Attachment(strReportName))
        client.Host = SMTP_server
        client.Port = SMTP_Port
        client.EnableSsl = SMTP_SSL
        client.UseDefaultCredentials = True
        client.Credentials = New Net.NetworkCredential(SMTP_User, SMTP_pass)

        client.Send(message)
        message.Dispose()


        txtName.Text = Nothing
        txtSectionName.Text = Nothing
        ddlTasks.SelectedIndex = 0
        System.IO.File.Delete(lblPictureFileName.Text)
        CrDiskFileDestinationOptions.DiskFileName = Nothing
        System.IO.File.Delete(strReportName)
        Session("myDatatable") = Nothing
        ddlTasks.SelectedIndex = ddlTasks.Items.IndexOf(ddlTasks.Items.FindByValue("< Select Task >"))

        myTable = Nothing
        gvAssignedTasks.DataSource = myTable
        gvAssignedTasks.Dispose()
        gvAssignedTasks.DataBind()

        lblMsg.Text = "Checklist has been sent"
        lblMsg.Visible = True

    End Sub

I have changed everything that I know.  I am on the old hosting and not using their PLESK hosting.  I changed the IIS to be Classic and not Integrated.  I am not sure what else to do.

If there is anything else that you need, please let me know.

Thanks!!

Eddi Rae


Viewing all articles
Browse latest Browse all 1507

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>