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

UnderSevenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi UnderSeven;

Where is the rest of the Parameter class?

Are you sure that you have a value in Session.Item("curStatement") ?
0
UnderSevenAuthor Commented:
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

0
Fernando SotoRetiredCommented:
In the initiatePublicSessionTransferRequest object has the parameters array been created and initialized?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

UnderSevenAuthor Commented:
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

0
Fernando SotoRetiredCommented:
You defined an array in the class but from what you have posted so far you have NOT created an instance of the array parameter.

''' Excerpts from your code
Private parametersField() As Parameter

'''<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

Open in new window


Somewhere you need to instantiate the array
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
UnderSevenAuthor Commented:
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.
0
Fernando SotoRetiredCommented:
On what line are you getting the exception? Please also post the exception and inner exception messages.
0
UnderSevenAuthor Commented:
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.
0
UnderSevenAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.