Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > Object reference not set to an instance of an object.
 

Object reference not set to an instance of an object.

I'm having a tough time with resolving this error. "Object reference not set to an instance of an object."   It's being generated on the following line.
params.strProps(0) = strs

I'm sure this is related to my inexperience, but if any can point me int he right direction, it would be appreciated. Here's the code snippet.

Dim node As New ParameterizedNode()

        node.nodeLabel = "Host"

        Dim params As New CIProperties()

        Dim strs As New StrProp()
        

        With strs

            .name = "ceg_appname"

            .value = app

        End With

        params.strProps(0) = strs

        req.parameterizedNodes(0) = node

I can provide the generated classes if necessary(Using Web Services interface).  CIProperties appears to be a collection. 
UberNoober  Wednesday, October 07, 2009 5:41 PM
Thanks for helping.  It's in the middle.

<System.Xml.Serialization.XmlArrayItemAttribute("strProp", IsNullable:=false)>  _
        Public Property strProps() As StrProp()
            Get
                Return Me.strPropsField
            End Get
            Set
                Me.strPropsField = value
            End Set
        End Property
Here's the StrProp code:
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.hp.com/ucmdb/1/types")>  _
    Partial Public Class StrProp
        Inherits CIProp
        
        Private valueField As String
        
        '''<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

Working backwards with the CIProp class:

<System.Xml.Serialization.XmlIncludeAttribute(GetType(XmlProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(StrProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(StrListProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(LongProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(IntProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(IntListProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(FloatProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(DoubleProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(DateProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(BytesProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(BooleanProp)),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.hp.com/ucmdb/1/types")>  _
    Partial Public MustInherit Class CIProp
        
        Private nameField As String
        
        '''<remarks/>
        Public Property name() As String
            Get
                Return Me.nameField
            End Get
            Set
                Me.nameField = value
            End Set
        End Property
    End Class
EDITED:  I worked it out.  Thanks for your help Matt!
UberNoober  Wednesday, October 07, 2009 6:12 PM
Not knowing what CIProperties() is, my guess would be, params.strProps collection object is not initialized to anything. What exactly is CIProperties?
Matt Wise  Wednesday, October 07, 2009 5:46 PM
Here's the code from the reference.vb file.  Not sure if this helps.

<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.hp.com/ucmdb/1/types")>  _
    Partial Public Class CIProperties
        
        Private datePropsField() As DateProp
        
        Private doublePropsField() As DoubleProp
        
        Private floatPropsField() As FloatProp
        
        Private intListPropsField() As IntListProp
        
        Private intPropsField() As IntProp
        
        Private strPropsField() As StrProp
        
        Private strListPropsField() As StrListProp
        
        Private longPropsField() As LongProp
        
        Private bytesPropsField() As BytesProp
        
        Private xmlPropsField() As XmlProp
        
        Private booleanPropsField() As BooleanProp
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("dateProp", IsNullable:=false)>  _
        Public Property dateProps() As DateProp()
            Get
                Return Me.datePropsField
            End Get
            Set
                Me.datePropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("doubleProp", IsNullable:=false)>  _
        Public Property doubleProps() As DoubleProp()
            Get
                Return Me.doublePropsField
            End Get
            Set
                Me.doublePropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("floatProp", IsNullable:=false)>  _
        Public Property floatProps() As FloatProp()
            Get
                Return Me.floatPropsField
            End Get
            Set
                Me.floatPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("intListProp", IsNullable:=false)>  _
        Public Property intListProps() As IntListProp()
            Get
                Return Me.intListPropsField
            End Get
            Set
                Me.intListPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("intProp", IsNullable:=false)>  _
        Public Property intProps() As IntProp()
            Get
                Return Me.intPropsField
            End Get
            Set
                Me.intPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("strProp", IsNullable:=false)>  _
        Public Property strProps() As StrProp()
            Get
                Return Me.strPropsField
            End Get
            Set
                Me.strPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("strListProp", IsNullable:=false)>  _
        Public Property strListProps() As StrListProp()
            Get
                Return Me.strListPropsField
            End Get
            Set
                Me.strListPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("longProp", IsNullable:=false)>  _
        Public Property longProps() As LongProp()
            Get
                Return Me.longPropsField
            End Get
            Set
                Me.longPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("bytesProp", IsNullable:=false)>  _
        Public Property bytesProps() As BytesProp()
            Get
                Return Me.bytesPropsField
            End Get
            Set
                Me.bytesPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("xmlProp", IsNullable:=false)>  _
        Public Property xmlProps() As XmlProp()
            Get
                Return Me.xmlPropsField
            End Get
            Set
                Me.xmlPropsField = value
            End Set
        End Property
        
        '''<remarks/>
        <System.Xml.Serialization.XmlArrayItemAttribute("booleanProp", IsNullable:=false)>  _
        Public Property booleanProps() As BooleanProp()
            Get
                Return Me.booleanPropsField
            End Get
            Set
                Me.booleanPropsField = value
            End Set
        End Property
    End Class
UberNoober  Wednesday, October 07, 2009 5:57 PM
What exactly is a StrProp? I don't see a definition for that.
Matt Wise  Wednesday, October 07, 2009 6:04 PM
Thanks for helping.  It's in the middle.

<System.Xml.Serialization.XmlArrayItemAttribute("strProp", IsNullable:=false)>  _
        Public Property strProps() As StrProp()
            Get
                Return Me.strPropsField
            End Get
            Set
                Me.strPropsField = value
            End Set
        End Property
Here's the StrProp code:
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.hp.com/ucmdb/1/types")>  _
    Partial Public Class StrProp
        Inherits CIProp
        
        Private valueField As String
        
        '''<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

Working backwards with the CIProp class:

<System.Xml.Serialization.XmlIncludeAttribute(GetType(XmlProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(StrProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(StrListProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(LongProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(IntProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(IntListProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(FloatProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(DoubleProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(DateProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(BytesProp)),  _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(BooleanProp)),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3053"),  _
     System.SerializableAttribute(),  _
     System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.ComponentModel.DesignerCategoryAttribute("code"),  _
     System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.hp.com/ucmdb/1/types")>  _
    Partial Public MustInherit Class CIProp
        
        Private nameField As String
        
        '''<remarks/>
        Public Property name() As String
            Get
                Return Me.nameField
            End Get
            Set
                Me.nameField = value
            End Set
        End Property
    End Class
EDITED:  I worked it out.  Thanks for your help Matt!
UberNoober  Wednesday, October 07, 2009 6:12 PM

You can use google to search for other answers

Custom Search

More Threads

• Webbrowser control and threading
• Reference to an open form from a global function
• dataset DefaultView.RowFilter problem
• What is the version of Windows Vista I need ?
• Reading a data file using streamreader
• Body Property of the Mail.MailMessage Object
• visual inheritance error
• Enum question
• Flusing mouse input ??
• Help for WPF application (Formatting a drive)