Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

nullreferenceexception was unhandled by user code

$
0
0
Hi,
I am developing an extension similar to American community Survey Mapping, I am trying to populate Combo box with TOC layers, or by using open command in my form, but I am getting nullreferenceexception was unhandled by user code error near:

Code:

Dim num2 As Integer = (strArray.Length - 1)
Also I am getting many warning messages like "Variable 'variableName' is passed by reference before it has been assigned a value. A null reference exception could result at runtime".

Here is part of the code where I get the error.

Code:

Private Sub CmdOpenFeture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdOpenFeture.Click
        Dim obj2 As IEnumGxObject
        Dim dialog As IGxDialog = New GxDialogClass
        Dim filters As IGxObjectFilterCollection = DirectCast(dialog, IGxObjectFilterCollection)
        Dim filter5 As IGxObjectFilter = New GxFilterTablesAndFeatureClassesClass
        Dim filter As IGxObjectFilter = New GxFilterPersonalGeodatabasesClass
        Dim filter2 As IGxObjectFilter = New GxFilterPGDBFeatureClassesClass
        Dim filter3 As IGxObjectFilter = New GxFilterPGDBFeatureDatasetsClass
        Dim filter4 As IGxObjectFilter = New GxFilterPGDBTablesClass
        filters.AddFilter(filter5, True)
        filters.AddFilter(filter, False)
        filters.AddFilter(filter3, False)
        filters.AddFilter(filter4, False)
        Dim dialog2 As IGxDialog = dialog
        dialog2.AllowMultiSelect = False
        dialog2.ButtonCaption = "Select"
        dialog2.Title = "Select Input File"
        Dim flag As Boolean = dialog2.DoModalOpen(0, obj2)
        dialog2 = Nothing
        If flag Then
            Dim strArray As String()
            Dim fullName As String = obj2.Next.FullName
            CboOpenfeature.Text = fullName
            InputDataCmd.readFieldFromFeature(fullName, (strArray))
            CboFeaturefield.Items.Clear()
            Dim num2 As Integer = (strArray.Length - 1)
            Dim i As Integer = 0
            Do While (i <= num2)
                CboFeaturefield.Items.Add(strArray(i))
                i += 1
            Loop
            TxtOutputPath.Text = (InputDataCmd.featureWorkspacePath & "\" & InputDataCmd.featureName & "_joined.shp")
        End If

    End Sub

I do appreciate your help
Thank you

Viewing all articles
Browse latest Browse all 1374

Trending Articles