Object reference not set to an instance of an object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dorandoran
    New Member
    • Feb 2007
    • 145

    Object reference not set to an instance of an object

    What could cause "Object reference not set to an instance of an object." error? I was trying to read the envelope table. I got the code from the 3rd link below.

    http://www.e-topco.com/oa/oa_help/OpenAir_SOAP.ht m
    http://www.e-topco.com/oa/oa_help/Complex_Types/Intro_Complex_T ypes.htm
    http://www.e-topco.com/oa/oa_help/Code_Examples/Code_Examples.h tm

    Here is the code I am using

    Code:
        Private Sub btnProject2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProject2.Click
    
            Dim stub As New com.openair.sandbox.OAirServiceHandlerService()
    
            Dim req As New ReadRequest()
            req.type = "Envelope"
            req.method = "all"
            Dim env1 As New oaEnvelope
    
            req.objects = New oaEnvelope() {env1}
            Try
                Dim results As ReadResult() = m_svc.read(New ReadRequest() {req})
    
                ' iterate through our results and output them to console
                For Each result As ReadResult In results
                    ' output any errors
                    If result.errors IsNot Nothing Then
                        For Each err As oaError In result.errors
                          MessageBox.Show("Error " + err.code + ": " + err.comment + "" & Chr(9) & "" + err.text)
                        Next
                    End If
    
                    ' output the envelope read results
                    If result.objects IsNot Nothing Then
                        MessageBox.Show("Received " + result.objects.Length + " envelope(s) from OpenAir")
                        For Each env As oaEnvelope In result.objects
                            MessageBox.Show(Chr(9) & "" + env.id + env.total + env.date + env.name + env.tottickets)
    
                        Next
                    End If
                Next
            Catch ex As Exception
                MessageBox.Show("Error while reading envelopes:" & Chr(10) & "" & ex.Message)
            End Try
        End Sub
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Do you know which line caused the error?

    Comment

    • dorandoran
      New Member
      • Feb 2007
      • 145

      #3
      result.objects is showing nothing when i stepped through the code and thats why it's giving me an error. but why it's showing nothing.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Is results ITSELF "nothing"?

        Comment

        • dorandoran
          New Member
          • Feb 2007
          • 145

          #5
          result is nothing. but i know for fact there are tons of records that i should get in return.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Well, I don't know what's going on here:
            Dim results As ReadResult() = m_svc.read(New ReadRequest() {req})

            but maybe check into that section?

            Comment

            Working...