cancel
Showing results for 
Search instead for 
Did you mean: 

Null Reference when zooming on hidden detail data.

Former Member
0 Kudos

This is really weird. I have users that have reported this error: "An unhandled exception of type 'System.NullReferenceException' occured in CrystalDecision.Windows.Forms.dll". I got some data from them and started playing around.

The report is an embedded report on vs2010 using crystal 2010 for vs sp1. The report is built off a dataset.xsd that I created from the data. The weird thing is that I can un-hide the details and zoom to the sub report for the section called "Resulting XML" just fine. But if I hide the details and try to zoom to the sub report, it crashes every time.

Any Ideas?

Edited by: Don Williams on Apr 19, 2011 12:49 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks for fixing the post!

I think I misled you by saying sub report. There isn't a sub report at all. I should have said drill down on a hidden section.

Since the Crystal needs a Strongly Typed data set, I create an XSD to represent the xml data that will come into the report.

[Data set image|www.theworldon-line.com/picts/capture.png]

[view of my report designer|www.theworldon-line.com/picts/Capture2.png]

I hope the links will help clarify and thanks for your help.

0 Kudos

Hi Greg,

Are you linking the 2 data sets? Also, It's never a good idea to use more than one. If you can build a query to get all of the data into one DS then this should work with causing a crash. It may be because the tables are not linked....

Thanks

Don

0 Kudos

We discovered there was a missing field for the Group header/footer which was causing the problem.

Fixing the report fixed the crash.

Thank you

Don

PS - please mark this as answered.

Answers (2)

Answers (2)

0 Kudos

Hi Greg,

2500 character limit and then forums removes formatting to save space I guess....

Wrapping your code in ( remove the spaces ) will retain the formatting, so I fixed your post for you.

Can we get a description of the how the report and subreport are designed? Possibly paste screen shots to the same place you posted your code?

Thank you

Don

0 Kudos

And Ludek and I talked this one over also. If you are using a subreport we don't see code to set the DS to the subreport, you may need to do that also.

And there is know issue under certain circumstances where you need to set the subreport log on/location info first.

Thank

Don

0 Kudos
Schema: 
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="RecordType">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Error">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="ErrorCategory" type="xs:string" />
                    <xs:element name="ErrorNumber" type="xs:unsignedByte" />
                    <xs:element name="ErrMsg" type="xs:string" />
                    <xs:element name="DataCode" type="xs:string" />
                    <xs:element minOccurs="0" name="RecordNumber" type="xs:unsignedByte" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="ID" type="xs:unsignedShort" use="required" />
            <xs:attribute name="ImportID" type="xs:string" use="required" />
            <xs:attribute name="Data" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Sample Data:

<?xml version="1.0" encoding="utf-8"?>
<root>
  <RecordType ID="0" ImportID="" Data="C:\Users\isemane\AppData\Roaming\Microsoft Corporation\Microsoft Dynamics GP\11.00.0221.000\_0.xml">
    <Error>
      <ErrorCategory />
      <ErrorNumber>0</ErrorNumber>
      <ErrMsg></ErrMsg>
      <DataCode></DataCode>
    </Error>
	</RecordType>	
  <RecordType ID="22115" ImportID="ETH PRIMARY PAY" Data="C:\Users\isemane\AppData\Roaming\Microsoft Corporation\Microsoft Dynamics GP\11.00.0221.000\ETH PRIMARY PAY_22115.xml">
    <Error>
      <ErrorCategory>Imported Records</ErrorCategory>
      <ErrorNumber>0</ErrorNumber>
      <ErrMsg>Record number :1 Imported</ErrMsg>
      <DataCode>POPRCTNM: RCT0001559909</DataCode>
      <RecordNumber>1</RecordNumber>
    </Error>
    <Error>
      <ErrorCategory>impPurchaseReceipts</ErrorCategory>
      <ErrorNumber>4</ErrorNumber>
      <ErrMsg>Microsoft.Dynamics.GP.eConnect.eConnectException: Sql procedure error codes returned:</ErrMsg>
      <DataCode>POPRCTNM: RCT0001559910</DataCode>
      <RecordNumber>2</RecordNumber>
    </Error>
    <Error>
      <ErrorCategory>Imported Records</ErrorCategory>
      <ErrorNumber>0</ErrorNumber>
      <ErrMsg>Record number :3 Imported</ErrMsg>
      <DataCode>POPRCTNM: RCT0001559911</DataCode>
      <RecordNumber>3</RecordNumber>
    </Error>
    <Error>
      <ErrorCategory>Imported Records</ErrorCategory>
      <ErrorNumber>0</ErrorNumber>
      <ErrMsg>Record number :4 Imported</ErrMsg>
      <DataCode>POPRCTNM: RCT0001559912</DataCode>
      <RecordNumber>4</RecordNumber>
    </Error>
    <Error>
      <ErrorCategory>impPurchaseReceipts</ErrorCategory>
      <ErrorNumber>4</ErrorNumber>
      <ErrMsg>Microsoft.Dynamics.GP.eConnect.eConnectException: Sql procedure error codes returned:</ErrMsg>
      <DataCode>POPRCTNM: RCT0001559913</DataCode>
      <RecordNumber>5</RecordNumber>
    </Error>
    <Error>
      <ErrorCategory>Imported Records</ErrorCategory>
      <ErrorNumber>0</ErrorNumber>
      <ErrMsg>Record number :6 Imported</ErrMsg>
      <DataCode>POPRCTNM: RCT0001559914</DataCode>
      <RecordNumber>6</RecordNumber>
    </Error>
    <Error>
      <ErrorCategory>Imported Records</ErrorCategory>
      <ErrorNumber>0</ErrorNumber>
      <ErrMsg>Record number :7 Imported</ErrMsg>
      <DataCode>POPRCTNM: RCT0001559915</DataCode>
      <RecordNumber>7</RecordNumber>
    </Error>
    <Error>
      <ErrorCategory>Resulting XML</ErrorCategory>
      <ErrorNumber>0</ErrorNumber>
      <ErrMsg>Start Time for impPurchaseReceipts: 4/18/2011 6:14:47 PM
End Time: 4/18/2011 6:17:42 PM
Elapsed Time: 0:3:54.2538
Records imported:5
Errors Found:2</ErrMsg>
      <DataCode>Import Results:Purchase Receipts</DataCode>
    </Error>
  </RecordType>
</root>

I load the data with the following code:<turns out this little editor doesn't like to cut and paste vb code, so I'll link it.>

[source code for load of xml|http://pastebin.com/k2At4pBC]

0 Kudos

Private Sub OpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFile.Click
        Me.OpenFileDialog1.Filter = "Error Logs (*.xml)|*.xml|All files (*.*)|*.*"
        Me.OpenFileDialog1.FilterIndex = 1
        Me.OpenFileDialog1.RestoreDirectory = True
        Me.OpenFileDialog1.CheckFileExists = True
        Me.OpenFileDialog1.CheckPathExists = True
        Me.OpenFileDialog1.Multiselect = False
 
        Dim rpt As New ConsoleErrorLog
 
        If Me.OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Try
 
            Catch ex As Exception
                MsgBox("Cannot read the file. Error: " & ex.Message)
            Finally
                Dim ds As New DataSet
                ds.ReadXml(Me.OpenFileDialog1.FileName)
 
                rpt.SetDataSource(ds)
                Me.CrystalReportViewer1.ReportSource = rpt
                Me.Show()
                Me.Refresh()
            End Try
        End If
    End Sub