13 Replies Latest reply: Feb 22, 2012 7:24 PM by Jon Rothlander RSS

Crystal "Error" without any details

Jon Rothlander
Currently Being Moderated

I am having an odd problem.  I am using CR for VS2010 and I have a report that works fine most of the time.  But occasionally i get an error that just says "Error" on the report view control.  No details or anything else is provided in regards to what the error might be.

 

What I am doing is using ASPX and caching a report (not able to use session here).  When the user pages, it pulls it from the cache and loads it to view page 2.  This is when the error occurs.  When paging or doing anything else with the viewer control.  When the reports loads back from cache, it crashes and I get "error".

 

The odd thing is that I can get it to work fine when I run the report initialy with the user selects a date range.  But when the user selects a date range I can view page one, then page two crashes with that odd error.  If they do not set a date range, everything works fine.  Something happens when the date range is passed into the report but only on page 2, 3, etc. when the cache report object is returned.

 

It's almost like the data parameters are causing the caching of the report object to fail.  That is pretty odd.   

 

I suspect that the report is not the issue and that we are looking at a data issue or something else.  But everything here looks good.  The report loads fine for page one.  So the report runs.  Without a date range the report runs file and pages and all of the viewer controls work fine as well.  But if I set a date range and pass that into the report, it only works on page 1.  Page 2 crashes.  Everything else crashes as well such as going to the last page of the report, zooming in/out, etc.

 

Any ideas what might cause something like this?  What does "Error" really tell me?  What might cause that very generic error message to display in the report control.  Obviously an error would... but I suspect certain types of errors would display like this.  Obviously errors such as... no data, cannot connect to the database, etc. will have real error messages.  Are there particular types of errors that do not display and just say "error"?

 

Any thoughts or suggestions would be very helpful.

 

Best regards,

Jon

  • Re: Crystal "Error" without any details
    Saurabh Pathak
    Currently Being Moderated

    Hi Jon,

     

    See if this helps...

    https://weblogs.sdn.sap.com/pub/wlg/26825

     

     

    - Saurabh

  • Re: Crystal "Error" without any details
    Ludek Uher
    Currently Being Moderated

    Hello Jon

     

     

    I've never seen this behavior, nor do I remember anyone else posting a similar issue. Make sure you are using SP2, both on your dev and runtime computers (see the sticky post at the top of this forum).

    If you are doing any error trapping, remove it for now, see if you get a different error / behavior.

    Also, please comment on why you are not able to use session at this time.

    Finally, I'd like  to see the following;

     

    Your CR code

    The CR related HTML code behind the aspx page that holds the viewer

     

     

     

    Ludek

    Follow us on Twitter http://twitter.com/SAPCRNetSup

    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

    • Re: Crystal "Error" without any details
      Jon Rothlander
      Currently Being Moderated

      How do I verify that I am running SP2?  The DLL references I am using version show version 13.0.2000.0.  I am only testing this currently on the development system.  It happens in developing, stagging, testing, and production.  So we are seeing the same pattern across all of our deployments.  But I can recreate it locally on my dev box as well.  So I should be ok in that regards to focus on my dev box to get this working. 

       

       

       

      >>If you are doing any error trapping, remove it for now, see if you get a different error / behavior.

      I do not have any error trapping around this.  The report looks to run fine when you are debugging.  The only time you noticed that it didn't work is when it renders in the ASPX Report Veiwer control and says "error".  Other than that, no errors are thrown in the code and every looks good. 

       

       

       

      When you view page 1, everything is great.  Then you go to page 2 and get the error.  Between page 1 and 2 the only thing going on is that the report object is being stored in cache and pulled back out again.  I give it a timeout of 20-minutes.  So it should be ok.  This works when I do not set a date range for my data and I get that error when I set a date range.  So the obvious issue is something in the report crashes with the date.  However, these reports run fine in production using version 10.2 of the Crystal runtime.  We updated to 13.2 and we started having issues.

       

       

      >>Also, please comment on why you are not able to use session at this time.

      Crystal does not work with session state managed by SQL server. 

       

       

      You have to run a RAS setup for that, which I do not have.  All of my problems come from not being able to store the report object in session.  Because the report object is not serializable I cannot store it in session.  So I am storing it in cache because that does not have to be serializable and is not managed by SQL Server. 

       

       

      It should work pretty much the same in regards to the functionality.  But pulling the report object back out of cache is not working when I have a date range on my parameters. That is VERY odd and it seems obvious that there is more to the issue that I cannot see here and I am still trying to nail down exactly what the issue is.  But all I know is that when I generate a report with null date values for the parameters, the report goes into cache without any issues and comes out without any issues. But when I have those input parameters set with valid date values, the report goes into cache without an issues but comes out with the "error" message being displayed.  I think that if the report itself had a bug in the date range code, that page 1 would not load.  Page 1 loads fine.  It's page 2, zooming, etc. that give me the "Error".  So it has to be related to caching the report object...  or so it seems. 

       

       

      >>Your CR code

      Are you talking about the RPT file itself.  I can email it to you if you like.  Here's the ASPX code behind that is loading it.

       

       

       

      Private Sub CreateReport()
      
              Dim myReport As New ReportDocument
              Dim mySubReport As New ReportDocument
              Dim myReportSections As Sections
              Dim myReportSection As Section
              Dim myReportObjects As ReportObjects
              Dim myReportObject As ReportObject
              Dim mySubReportObject As SubreportObject
      
              'Load the report
              myReport.Load(ConfigurationManager.AppSettings("CrystalShare").ToString().TrimEnd("\"c) & "\" & Report)
      
              ' Loop through every table in the report.
              For i As Integer = 0 To myReport.Database.Tables.Count - 1
                  ' Set the connection information for current table.
                  myReport.Database.Tables.Item(i).ApplyLogOnInfo(URSIS.Legacy.Crystal.GetCrystalLogonInfo())
              Next (i)
      
              'Set the sections collection with report sections 
              myReportSections = myReport.ReportDefinition.Sections
              'Loop through each section and find all the report objects 
              'Loop through all the report objects to find all subreport objects, then set the 
              'logoninfo to the subreport 
              For Each myReportSection In myReportSections
                  myReportObjects = myReportSection.ReportObjects
                  For Each myReportObject In myReportObjects
                      If myReportObject.Kind = ReportObjectKind.SubreportObject Then
      
                          'If you find a subreport, typecast the reportobject to a subreport object 
                          mySubReportObject = CType(myReportObject, SubreportObject)
      
                          'Open the subreport 
                          mySubReport = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
      
                          For i As Integer = 0 To mySubReport.Database.Tables.Count - 1
                              ' Set the connection information for current table.
                              mySubReport.Database.Tables.Item(i).ApplyLogOnInfo(URSIS.Legacy.Crystal.GetCrystalLogonInfo())
                          Next i
                      End If
                  Next
              Next
      
              Dim parFields As New ParameterFields
              Dim parField As ParameterField
              Dim parValue As ParameterDiscreteValue
              Dim parValues As ParameterValues
              Dim paramCount As Integer = 0
              Dim paramValuesCount As Integer = 0
      
              If Not IsNothing(_params) Then
                  paramCount = _params.Length
              End If
              If Not IsNothing(_paramValues) Then
                  paramValuesCount = _paramValues.Length
              End If
              If Not IsNothing(_params) And Not IsNothing(_paramValues) Then
                  If _params.Length = _paramValues.Length Then
                      For i As Integer = 0 To _params.Length - 1
                          parField = New ParameterField
                          parField.ParameterFieldName = _params.GetValue(i).ToString()
                          parValues = New ParameterValues
                          parValue = New ParameterDiscreteValue
                          If TypeOf (_paramValues.GetValue(i)) Is Array Then
                              For j As Integer = 0 To CType(_paramValues.GetValue(i), Object()).Length - 1
                                  parValue.Value = CType(_paramValues.GetValue(i), Object())(j)
                                  parValues.Add(parValue)
                              Next
                          Else
                              parValue.Value = _paramValues.GetValue(i)
                              parValues.Add(parValue)
                          End If
                          parField.CurrentValues = parValues
                          parFields.Add(parField)
                      Next
                  Else
                      lblError.Text = "The number of parameters and the number of parameter values are not equal"
                      Return
                  End If
              End If
      
              Dim countParams As Integer = 0
              For Each param As ParameterField In myReport.ParameterFields
                  If param.ReportName.Length = 0 Then
                      countParams += 1
                  End If
              Next
              If paramCount <> countParams Or paramValuesCount <> countParams Then
                  lblError.Text = "The report has more parameters defined than was supplied, please contact your administrator"
                  Return
              End If
      
              Try
                  myReport.VerifyDatabase()
              Catch ex As Exception
                  'MsgBox(ex.Message & " " & ex.InnerException.ToString(), MsgBoxStyle.Information, "Error")
              End Try
      
              CrystalReportViewer1.ReportSource = myReport
              CrystalReportViewer1.ParameterFieldInfo = parFields
              CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None
              Session.Add("CrystalReportDoc", True)
              Cache.Insert("CrystalReportDoc", myReport, Nothing, DateTime.Now.AddMinutes(_cacheTimeout), TimeSpan.Zero)
          End Sub
      
      
      Private Sub LoadReport()
              If Not IsNothing(ViewState("ReportShown")) Then
                  If ViewState("ReportShown").ToString() = "True" Then
                      If Session("CrystalReportDoc") IsNot Nothing Then
                              CrystalReportViewer1.ReportSource = CType(Cache.Get("CrystalReportDoc"), CrystalDecisions.CrystalReports.Engine.ReportDocument)
                          Else
                              lblError.Text = Resource1.CrystalReport_LoadReport_Report_Timed_Out_Message
                          End If
                      End If
                  End If
              End If
          End Sub
      
      <CR:CrystalReportViewer ID="CrystalReportViewer1" AutoDataBind="true" 
          runat="server" Width="350px" Height="50px" PrintMode="ActiveX" 
          EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False" 
          ViewStateMode="Enabled"></CR:CrystalReportViewer>
      
      
      

       

      Jon

       

      Edited by: jrothlander on Feb 21, 2012 5:51 PM

      • Re: Crystal "Error" without any details
        Jon Rothlander
        Currently Being Moderated

        My last reply is not formatting correctly.  When I edit it, it looks fine.  But all of the spacing and line feeds are missing.  Do you know how to fix that?

         

        Jon

        • Re: Crystal "Error" without any details
          Jon Rothlander
          Currently Being Moderated

          Trying to repost the message from above that is not formatted. 

           

          How do I verify that I am running SP2? The DLL references I am using version show version 13.0.2000.0. I am only testing this currently on the development system. It happens in developing, stagging, testing, and production. So we are seeing the same pattern across all of our deployments. But I can recreate it locally on my dev box as well. So I should be ok in that regards to focus on my dev box to get this working.

           

          >>If you are doing any error trapping, remove it for now, see if you get a different error / behavior. I do not have any error trapping around this. The report looks to run fine when you are debugging. The only time you noticed that it didn't work is when it renders in the ASPX Report Veiwer control and says "error". Other than that, no errors are thrown in the code and every looks good. When you view page 1, everything is great. Then you go to page 2 and get the error. Between page 1 and 2 the only thing going on is that the report object is being stored in cache and pulled back out again. I give it a timeout of 20-minutes. So it should be ok. This works when I do not set a date range for my data and I get that error when I set a date range. So the obvious issue is something in the report crashes with the date. However, these reports run fine in production using version 10.2 of the Crystal runtime. We updated to 13.2 and we started having issues.

           

          >>Also, please comment on why you are not able to use session at this time.

          Crystal does not work with session state managed by SQL server.

           

          You have to run a RAS setup for that, which I do not have. All of my problems come from not being able to store the report object in session. Because the report object is not serializable I cannot store it in session. So I am storing it in cache because that does not have to be serializable and is not managed by SQL Server. It should work pretty much the same in regards to the functionality. But pulling the report object back out of cache is not working when I have a date range on my parameters. That is VERY odd and it seems obvious that there is more to the issue that I cannot see here and I am still trying to nail down exactly what the issue is. But all I know is that when I generate a report with null date values for the parameters, the report goes into cache without any issues and comes out without any issues. But when I have those input parameters set with valid date values, the report goes into cache without an issues but comes out with the "error" message being displayed. I think that if the report itself had a bug in the date range code, that page 1 would not load. Page 1 loads fine. It's page 2, zooming, etc. that give me the "Error". So it has to be related to caching the report object... or so it seems.

           

           

          >>Your CR code

          Are you talking about the RPT file itself. I can email it to you if you like.

           

          I'll post the code seperatly.  Maybe that is what is messing up the formatting.

          • Re: Crystal "Error" without any details
            Jon Rothlander
            Currently Being Moderated

            I can send you the RPT itself.  Maybe something is messed up that I cannot see.

             

            The ASPX code is just the control.  We nest this in a page via a web control.  There is not much here.  The parent page has a lot of formatting around it and the date selections.  But as far as the CR code goes, this is all that is in the ASPX.

             

            <CR:CrystalReportViewer ID="CrystalReportViewer1" AutoDataBind="true" 
                runat="server" Width="350px" Height="50px" PrintMode="ActiveX" 
                EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False" 
                ViewStateMode="Enabled"></CR:CrystalReportViewer>

             

            Here is the actual code that loads the report.  I inherited this code from someone else.  I am not sure why they are doing all of the work they are doing here.  But it works fine.  So I have not touched it.  All I added was the very last line of code that put it into cache.  Then I modified another line that pulls it back out.  This works fine for reports without a date range and works fine for page 1 with the date range.  It fails on page 2, zooming, etc.  Which means that when it comes back out of cache it fails for the reports that have a date range.  That is why it is so odd.  I have been looking at issues where it doesn't get loaded from cache and might be empty, where it gets overwritten, or anything having to do with not pulling it from cache correctly or not putting it into cache correctly.  All of that seems fine and works when I do not have date range specified in the report.

             

            I'll post the code-behind in a seperate post.  The forum cannot handle the formatting of this and it will not display correctly.  You can see that in a few postings back.

             

            Edited by: jrothlander on Feb 21, 2012 6:00 PM

            • Re: Crystal "Error" without any details
              Jon Rothlander
              Currently Being Moderated

              The forum doesn't seem to like formatting the code below!  But here it is.  It might be better to copy it into .Net and see it formatted correctly.

               

               

              
              Private Sub CreateReport()
                      Dim myReport As New ReportDocument
                      Dim mySubReport As New ReportDocument
                      Dim myReportSections As Sections
                      Dim myReportSection As Section
                      Dim myReportObjects As ReportObjects
                      Dim myReportObject As ReportObject
                      Dim mySubReportObject As SubreportObject
              
                      'Load the report
                      myReport.Load(ConfigurationManager.AppSettings("CrystalShare").ToString().TrimEnd("\"c) & "\" & Report)
              
                      ' Loop through every table in the report.
                      For i As Integer = 0 To myReport.Database.Tables.Count - 1
                          ' Set the connection information for current table.
                          myReport.Database.Tables.Item(i).ApplyLogOnInfo(URSIS.Legacy.Crystal.GetCrystalLogonInfo())
                      Next (i)
              
                      'Set the sections collection with report sections 
                      myReportSections = myReport.ReportDefinition.Sections
                      'Loop through each section and find all the report objects 
                      'Loop through all the report objects to find all subreport objects, then set the 
                      'logoninfo to the subreport 
                      For Each myReportSection In myReportSections
                          myReportObjects = myReportSection.ReportObjects
                          For Each myReportObject In myReportObjects
                              If myReportObject.Kind = ReportObjectKind.SubreportObject Then
              
                                  'If you find a subreport, typecast the reportobject to a subreport object 
                                  mySubReportObject = CType(myReportObject, SubreportObject)
              
                                  'Open the subreport 
                                  mySubReport = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
              
                                  For i As Integer = 0 To mySubReport.Database.Tables.Count - 1
                                      ' Set the connection information for current table.
                                      mySubReport.Database.Tables.Item(i).ApplyLogOnInfo(URSIS.Legacy.Crystal.GetCrystalLogonInfo())
                                  Next i
                              End If
                          Next
                      Next
              
               

               

              Edited by: Ludek Uher on Feb 21, 2012 9:19 AM

              • Re: Crystal "Error" without any details
                Ludek Uher
                Currently Being Moderated

                Code continued:

                 

                 

                
                
                        Dim parFields As New ParameterFields
                        Dim parField As ParameterField
                        Dim parValue As ParameterDiscreteValue
                        Dim parValues As ParameterValues
                        Dim paramCount As Integer = 0
                        Dim paramValuesCount As Integer = 0
                
                        If Not IsNothing(_params) Then
                            paramCount = _params.Length
                        End If
                        If Not IsNothing(_paramValues) Then
                            paramValuesCount = _paramValues.Length
                        End If
                        If Not IsNothing(_params) And Not IsNothing(_paramValues) Then
                            If _params.Length = _paramValues.Length Then
                                For i As Integer = 0 To _params.Length - 1
                                    parField = New ParameterField
                                    parField.ParameterFieldName = _params.GetValue(i).ToString()
                                    parValues = New ParameterValues
                                    parValue = New ParameterDiscreteValue
                                    If TypeOf (_paramValues.GetValue(i)) Is Array Then
                                        For j As Integer = 0 To CType(_paramValues.GetValue(i), Object()).Length - 1
                                            parValue.Value = CType(_paramValues.GetValue(i), Object())(j)
                                            parValues.Add(parValue)
                                        Next
                                    Else
                                        parValue.Value = _paramValues.GetValue(i)
                                        parValues.Add(parValue)
                                    End If
                                    parField.CurrentValues = parValues
                                    parFields.Add(parField)
                                Next
                            Else
                                lblError.Text = "The number of parameters and the number of parameter values are not equal"
                                Return
                            End If
                        End If
                
                        Dim countParams As Integer = 0
                        For Each param As ParameterField In myReport.ParameterFields
                            If param.ReportName.Length = 0 Then
                                countParams += 1
                            End If
                        Next
                        If paramCount <> countParams Or paramValuesCount <> countParams Then
                            lblError.Text = "The report has more parameters defined than was supplied, please contact your administrator"
                            Return
                        End If
                
                        Try
                            myReport.VerifyDatabase()
                        Catch ex As Exception
                            'MsgBox(ex.Message & " " & ex.InnerException.ToString(), MsgBoxStyle.Information, "Error")
                        End Try
                
                        CrystalReportViewer1.ReportSource = myReport
                        CrystalReportViewer1.ParameterFieldInfo = parFields
                        CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None
                        Session.Add("CrystalReportDoc", True)
                        Cache.Insert("CrystalReportDoc", myReport, Nothing, DateTime.Now.AddMinutes(_cacheTimeout), TimeSpan.Zero)
                    End Sub
                
                    Private Sub LoadReport()
                        If Not IsNothing(ViewState("ReportShown")) Then
                            If ViewState("ReportShown").ToString() = "True" Then
                                If Session("CrystalReportDoc") IsNot Nothing Then
                                        CrystalReportViewer1.ReportSource = CType(Cache.Get("CrystalReportDoc"), CrystalDecisions.CrystalReports.Engine.ReportDocument)
                                    Else
                                        lblError.Text = Resource1.CrystalReport_LoadReport_Report_Timed_Out_Message
                                    End If
                                End If
                            End If
                        End If
                    End Sub

                 

              • Re: Crystal "Error" without any details
                Jon Rothlander
                Currently Being Moderated

                I did flip it back to using session and the same thing happens.  So it is NOT cache versus session issue.

                 

                I can use session on my local development box because it is not using SQL Server to manage the session state.  But when I deploy this to production, I cannot use session because that server is using SQL Sever to manage the session state and Crystal Reports for .Net 2010 cannot support that.

                 

                Jon

                • Re: Crystal "Error" without any details
                  Jon Rothlander
                  Currently Being Moderated

                  What about the following code?  If I set the report and paraemeter fields, when I pull the report back out from session or cache, do I need to do anything to set those back up?  I am not executing the report per say to get to page 2, but does Crystal run the report again?  Maybe I need to store the parFields as well? 

                   

                  I am using session for now and I will flip it back to use the cache later.  I don't want to introduce any issues by using the cache.  But it should work basically the same to solve my issue. 

                   

                  CrystalReportViewer1.ReportSource = myReport
                  CrystalReportViewer1.ParameterFieldInfo = parFields
                  CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None
                  Session.Add("CrystalReportDoc", myReport)

                   

                  I'm not very familiar with Crystal so don't assume I know anything about what is going on here.  These reports were developed in 2001, 2002, 2003 timeframe and upgraded to v10.2 a while back.  No one touches the reports anymore.  So I am not very fimilar with Crystal or the reports.

                  • Re: Crystal "Error" without any details
                    Jon Rothlander
                    Currently Being Moderated

                    Thanks for the comments and suggestions.  But now I don't think this is an issue with CR, session, or cache. 

                     

                    I built a seperate test page just to test this with and it worked fine there.  Whatever the problem is, I don't think it is with Crystal.

                    • Re: Crystal "Error" without any details
                      Ludek Uher
                      Currently Being Moderated

                      Interesting. I have asked someone else to also have a look - irrespective. The more brain power the better, so we'll see. But if you find out anything, it would be so great if you could find the time to share

                       

                       

                      - Ludek

                      • Re: Crystal "Error" without any details
                        Jon Rothlander
                        Currently Being Moderated

                        I figured out what the issue was.  It looks like something changed in how Crystal Reports handles input parameter objects between versions v.10.2 and v.13.2 in regards to serialization and deserialization to store the report object in session or cache.  There seems to be an bug in the Crystal Engine that causes a runtime error to occur in the engine and hense we only get "Error" in the report viewer control.  This was not an issue in v.10.2 but it no longer works in v.13.2.  But I figured out what the issue is and how to work around it.  But it may be something worth turning in to have resolved in a future release.  

                         

                        In the older code that works in Crystal Reports v10.2 it allowed an object of type of object to be passed in as an parameterfield.  If that object contained a date datatype, such as...

                         

                        Dim frmDate as Object

                        Dim toDate as Object

                         

                        frmDate = Now

                        toDate = Now

                         

                        Now pass that into a report with input field parameters for a date datatype.  Page one will work.  Push it into session and pull it back out to get to page two.  You will get a runtime error in the Crystal Engine.  It cannot pull the object back out as an object.  I flipped it to a date datetype and it still did not work.  I flipped it to a string and it worked fine.

                         

                        It appears that the serialization and deserialization process for the report object to be stored in session requires that a string value be passed from the .Net code into the report.  The report parameter field is of type datetime.  If you pass in a object that has a date object within, it will fail.  If you pass in a date object, it will fail.  If you pass in a DateTime, it will fail.  If you pass in a string, it works.  Apparently the Crystal Engine is coded to serialize a string for the ParameterField when the datatype of the parameter is datetime.  By passing in a string you are ok.  But the other datatypes should work.  They work fine if you do not store it in session.  So it's purely an issue with the serialization process. 

                         

                        The fact that it works for page 1 tells us that the Crystal Report engine can handle it as an object type that is set to a DateTime.  What fails is the serialization process to pull it back out.  That makes sense why the error we are seeing is just "Error".  That is because the serialization and deserialization process has failed and we get a runtime error in the Crystal Engine and it is unexpected and apparently untrapped as well.

                         

                        How I fixed it.  I just stopped using the object type and created it as a string.  That worked fine.  I did test using a datetime and a date datatype as well.  None of those work.  Only a string works.

                         

                        Jon Rothlander

                         

                        Edited by: jrothlander on Feb 22, 2012 7:24 PM

Actions