none
Visual Studio ReportViewer Freezes while Trying to Export RRS feed

  • Question

  • Hi ,
    Please can someone help me with this issue :

    I am using VS2005, VB.net,WinForms,    on windows 7

    In my application I have A reportViewer control on a form , the form is opened via a thread (so that multiple reports can be opened at the same time) the reports open fine , but when trying to use any of the Export functionality , It freezes and doesnt display the Save as Dialogue box.
    If I dont thread it  , I can access the report and export Functionality perfectly.

    Please see code below:


     ThreadPreview = New Threading.Thread(AddressOf runPreview)
                            Me.LblLoadingReport.Visible = True
                            Me.LblLoadingReport.Text = TextRequestingInfo
                            PictureBox1.Visible = True
                            Application.DoEvents()
                            ThreadPreview.Start()
                            ' Application.DoEvents()





     Sub runPreview()
            Preview(guidString)
        End Sub


      Private Sub Preview(ByVal reportguid As String)
            Dim strPath As String = Nothing
            Dim oValue As Object = Nothing
            Dim strSPName As String = Nothing
            Dim strReportName As String = Nothing
            Dim dsReportData As DataSet = Nothing
            Dim homReports As WPS.Reports.ReportsHome = Nothing
            Dim strParameters As String = Nothing
            Dim blnSuccess As Boolean
            Dim intRowNumber As Int32
            Dim strParameterName As String = Nothing
            Dim strDataType As String = Nothing
            Dim strFileName As String = Nothing
            Dim oAlternateValue As Object = Nothing
            Dim iRow As Integer
            Dim iCol As Integer
            Dim itest As Integer
            Dim iTest2 As Integer
            Dim Table0Check As Boolean
            Dim InitialReportEmptyCheck As Boolean
            Dim objReportCheck As WPS.Reports.Reports
            Dim objNode As TreeNode = Nothing
            Dim timeOutPeriod As Integer = 0
            Dim dsReportsMulti(multiGuidsCount - 1) As DataSet


            Try

     Dim frmReportViewerSQL As New frmReportViewerSQL
                                frmReportViewerSQL.reportLoc = objReportCheck.reportNameOnServer
                                frmReportViewerSQL.reportURL = objReportCheck.reportServerURL
                                frmReportViewerSQL.timeOut = timeOutPeriod
                                frmReportViewerSQL.objReports = objReportCheck
                                frmReportViewerSQL.Text = objReportCheck.reportName
                                frmReportViewerSQL.reportParamaters = strParameters
                                'Add Network Credentials Parameters
                                frmReportViewerSQL.useNetorkCredentials = objReportCheck.useNetworkCredentials
                                frmReportViewerSQL.NCDomain = objReportCheck.NCDomain
                                frmReportViewerSQL.NCPassword = objReportCheck.NCPassword
                                frmReportViewerSQL.NCUsername = objReportCheck.NCUsername

                                frmReportViewerSQL.BringToFront()
                                frmReportViewerSQL.WindowState = FormWindowState.Maximized
      frmReportViewerSQL.ShowDialog()

      Catch ex As Exception
                ExceptionHandler(ex, False)
            End Try


        End Sub


    On the form with the reportviewer :

    Try
                If reportViewer.InvokeRequired Then

                    reportViewer.Invoke(New MethodInvoker(AddressOf loadReport))
                Else

                    Dim paramater As String = ""
                    Dim dsReportParameters As System.Collections.ArrayList
                    dsReportParameters = objReports.ReportParameters_Reports
                    Me.reportViewer.ServerReport.ReportServerUrl = New Uri(objReports.reportServerURL.ToString())
                    Me.reportViewer.ServerReport.ReportPath = objReports.reportNameOnServer
                    Me.reportViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote
                    Me.reportViewer.ShowParameterPrompts = False
                    Me.reportViewer.ServerReport.Timeout = timeOut
                    '   Dim arrReportParams(dsReportParameters.Count - 1) As System.Collections.Generic.IEnumerable(Of Microsoft.Reporting.WinForms.ReportParameter())
                    ' Microsoft.Reporting.WinForms.ReportParameter
                    Dim arrReportParams(dsReportParameters.Count - 1) As Microsoft.Reporting.WinForms.ReportParameter

                    'check if you need to use Network Credentials
                    If (useNetorkCredentials = True) Then
                        Dim Credential As Net.NetworkCredential
                        If Not (NCDomain Is Nothing) Then
                            If (NCDomain <> "") Then
                                Credential = New Net.NetworkCredential(NCUsername, NCPassword, NCDomain)
                            Else
                                Credential = New Net.NetworkCredential(NCUsername, NCPassword)
                            End If
                        Else
                            Credential = New Net.NetworkCredential(NCUsername, NCPassword)
                        End If


                        Me.reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials = Credential
                    End If




                    reportParamaters = reportParamaters.Replace("'", "")
                    Dim counter As Integer = 0
                    Dim currentParamNumber = 1
                    Dim x As Integer = 0
                    Dim objReportParamater1 As WPS.Reports.ReportParameters

                    While counter < arrReportParams.Length
                        objReportParamater1 = CType(dsReportParameters(x), WPS.Reports.ReportParameters)

                        If currentParamNumber = objReportParamater1.parameterNumber Then
                            Dim pos As Integer = reportParamaters.IndexOf(",")
                            If pos > 0 Then
                                paramater = reportParamaters.Substring(0, pos)
                                reportParamaters = reportParamaters.Substring(pos + 1)
                            Else
                                paramater = reportParamaters
                            End If

                            arrReportParams(counter) = New Microsoft.Reporting.WinForms.ReportParameter(objReportParamater1.TheReportsStoredProcFieldNames.StoredProcVariableName, paramater)
                            'objReportParamater.TheReportsStoredProcFieldNames.StoredProcVariableName
                            counter = counter + 1
                            currentParamNumber = currentParamNumber + 1
                            x = 0
                        Else
                            x = x + 1
                        End If

                    End While

                    '    Me.reportViewer.ServerReport.SetParameters()
                    Me.reportViewer.ServerReport.SetParameters(arrReportParams)
                    Me.reportViewer.RefreshReport()
                End If
            Catch ex As Exception
                MessageBox.Show("Error " + ex.Message.ToString(), "Error")
            End Try


    Thanks.
    Thursday, March 11, 2010 11:31 AM