How to fix a Object Reference Error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mbewers1
    New Member
    • Feb 2009
    • 68

    #1

    How to fix a Object Reference Error?

    Hi

    The method below fails on the line marked in bold and I receive an object reference error. I know that this is a common error but, I've tried changing several assignments to ensure they match up with the required types and it the method still fails.

    I also tried:

    Code:
    agentResponse(0).InputData = testMetaDataArray
    without the () after .InputData, but that still fails as well.

    Just for extra information:

    MetaDataRespons eSet is an array type and is what is required by the AgentResponseTo DTO() method.

    MetaDataGroup is also an array type which has various properties, the only two I need to assign to are .Name and .Size

    Code:
    Public Sub TestAgentResponseToDTOResponseFieldSize2()
    
            Dim agentResponse(0) As MetaDataResponseSet
    
            ''Create a MetaDataGroup object that can store 2 items
            Dim testMetaDataArray(1) As MetaDataGroup
    
            Dim mdaObject1 As MetaDataGroup = New MetaDataGroup()
            mdaObject1.Name = "my name"
            mdaObject1.Size = 3
    
            Dim mdaObject2 As MetaDataGroup = New MetaDataGroup()
            mdaObject2.Name = "is Mathieu"
            mdaObject2.Size = 6
    
            testMetaDataArray(0) = mdaObject1
            testMetaDataArray(1) = mdaObject2
    
            'testMetaDataArray(0).Name = "my name"
            'testMetaDataArray(0).Size = 3
    
            
            [B]agentResponse(0).InputData() = testMetaDataArray[/B] '' fails here
    
            '' Create a result object
            Dim result As Boolean = True
    
            Dim assemblerResponse = ExperianBankValMetaDataCallAssembler.AgentResponseToDTO(agentResponse)
    
            Assert.AreEqual(agentResponse(0).InputData(0).Size, assemblerResponse.InputFields(0).Length)
            Assert.AreEqual(agentResponse(0).InputData(0).Name, assemblerResponse.InputFields(0).Name)
    
            Assert.AreEqual(agentResponse(0).InputData(1).Size, assemblerResponse.InputFields(1).Length)
            Assert.AreEqual(agentResponse(0).InputData(1).Name, assemblerResponse.InputFields(1).Name)
    
            Assert.AreEqual(result, assemblerResponse.Result.Success)
    
        End Sub
    I hope that you can clearly understand this method without me having to show the related class code.

    Can anyone see where I've gone wrong?

    Thank, Matt
Working...