Link to home
Start Free TrialLog in
Avatar of UnderSeven
UnderSeven

asked on

Object not set to instance error when trying to instance object.

Here is my code
 Dim objXMLHTTP As New MSXML2.ServerXMLHTTP60()


            Dim service As New pconWSService.pconWSService
            Dim response As New pconWSService.InitiateSessionTransferResponse
            Dim initiatePublicSessionTransferRequest As New pconWSService.InitiatePublicSessionTransferRequest

            initiatePublicSessionTransferRequest.parameters(0) = New pconWSService.Parameter With {.name = "StatementNo", .value = Session.Item("curStatement")}

Open in new window


The last line is throwing the object refernce not set error.

This is the object definition:

 Partial Public Class Parameter
        
        Private nameField As String
        
        Private valueField As String
        
        '''<remarks/>
        Public Property name() As String
            Get
                Return Me.nameField
            End Get
            Set
                Me.nameField = value
            End Set
        End Property

Open in new window

Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Hi UnderSeven;

Where is the rest of the Parameter class?

Are you sure that you have a value in Session.Item("curStatement") ?
Avatar of UnderSeven
UnderSeven

ASKER

Here is the entire class.  For the sake of simplicity I've hard coded that value,

       initiatePublicSessionTransferRequest.parameters(0) = New pconWSService.Parameter With {.name = "StatementNo", .value = "1"}

    Partial Public Class Parameter
        
        Private nameField As String
        
        Private valueField As String
        
        '''<remarks/>
        Public Property name() As String
            Get
                Return Me.nameField
            End Get
            Set
                Me.nameField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property value() As String
            Get
                Return Me.valueField
            End Get
            Set
                Me.valueField = value
            End Set
        End Property
    End Class

Open in new window

In the initiatePublicSessionTransferRequest object has the parameters array been created and initialized?
It's part of the initiatepublictransferrequest class.  I thought, here is that definition.

I assumed I was missing something obvious.

 Partial Public Class InitiatePublicSessionTransferRequest
        
        Private billerGroupIdField As String
        
        Private billerIdField As String
        
        Private productCodeField As String
        
        Private billerPayorIdField As String
        
        Private amountDueField As System.Nullable(Of Decimal)
        
        Private amountDueTbdField As Boolean
        
        Private dueDateField As System.Nullable(Of Date)
        
        Private dueDateTbdField As Boolean
        
        Private level2SalesTaxAmountField As System.Nullable(Of Decimal)
        
        Private level2CustomerReferenceNumberField As String
        
        Private userIdField As String
        
        Private localeField As String
        
        Private parametersField() As Parameter
        
        Private disallowLoginField As System.Nullable(Of Boolean)
        
        Private returnSessionIdField As String
        
        Private returnUrlField As String
        
        '''<remarks/>
        Public Property billerGroupId() As String
            Get
                Return Me.billerGroupIdField
            End Get
            Set
                Me.billerGroupIdField = value
            End Set
        End Property
        
        '''<remarks/>
        Public Property billerId() As String
            Get
                Return Me.billerIdField
            End Get
            Set
                Me.billerIdField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property productCode() As String
            Get
                Return Me.productCodeField
            End Get
            Set
                Me.productCodeField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property billerPayorId() As String
            Get
                Return Me.billerPayorIdField
            End Get
            Set
                Me.billerPayorIdField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property amountDue() As System.Nullable(Of Decimal)
            Get
                Return Me.amountDueField
            End Get
            Set
                Me.amountDueField = value
            End Set
        End Property
        
        '''<remarks/>
        Public Property amountDueTbd() As Boolean
            Get
                Return Me.amountDueTbdField
            End Get
            Set
                Me.amountDueTbdField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(DataType:="date", IsNullable:=true)>  _
        Public Property dueDate() As System.Nullable(Of Date)
            Get
                Return Me.dueDateField
            End Get
            Set
                Me.dueDateField = value
            End Set
        End Property
        
        '''<remarks/>
        Public Property dueDateTbd() As Boolean
            Get
                Return Me.dueDateTbdField
            End Get
            Set
                Me.dueDateTbdField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property level2SalesTaxAmount() As System.Nullable(Of Decimal)
            Get
                Return Me.level2SalesTaxAmountField
            End Get
            Set
                Me.level2SalesTaxAmountField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property level2CustomerReferenceNumber() As String
            Get
                Return Me.level2CustomerReferenceNumberField
            End Get
            Set
                Me.level2CustomerReferenceNumberField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property userId() As String
            Get
                Return Me.userIdField
            End Get
            Set
                Me.userIdField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property locale() As String
            Get
                Return Me.localeField
            End Get
            Set
                Me.localeField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayAttribute(IsNullable:=true),  _
         System.Xml.Serialization.XmlArrayItemAttribute("parameter", IsNullable:=false)>  _
        Public Property parameters() As Parameter()
            Get
                Return Me.parametersField
            End Get
            Set
                Me.parametersField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property disallowLogin() As System.Nullable(Of Boolean)
            Get
                Return Me.disallowLoginField
            End Get
            Set
                Me.disallowLoginField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property returnSessionId() As String
            Get
                Return Me.returnSessionIdField
            End Get
            Set
                Me.returnSessionIdField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>  _
        Public Property returnUrl() As String
            Get
                Return Me.returnUrlField
            End Get
            Set
                Me.returnUrlField = value
            End Set
        End Property
    End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wouldn't this in theory instantiate the array:

Dim initiatePublicSessionTransferRequest.parameters() as pconWSService.Parameter

initiatePublicSessionTransferRequest.parameters = New pconWSService.Parameter() With {.name = "StatementNo", .value = Session.Item("curStatement")}

But it is tellig me exepecting end of statement on the dim statement and on the latter statement that it can't convert pconWSService.parameter() to a one dimiensional array.  

I'm still confused what I'm doing wrong.
On what line are you getting the exception? Please also post the exception and inner exception messages.
Dim initiatePublicSessionTransferRequest.parameters() as InitiatePublicSessionTransferRequest.parameters

First bolded: end of statement expected

It won't compile at this poitn so I can't give inner exceptions.
This is the solution.  More or less what you said it would be.

Dim initiatePublicSessionTransferRequest As pconWSService.InitiatePublicSessionTransferRequest = New pconWSService.InitiatePublicSessionTransferRequest


                Dim paramfields(0) As pconWSService.Parameter

                paramfields(0) = New pconWSService.Parameter With {.name = "StatementNo", .value = Session.Item("curStatement")}

                initiatePublicSessionTransferRequest.parameters = paramfields