Error on Non-Geometric when Looping Through Components

I have a loop to grab components and add them to an array to use later. It is erroring when it encounters a Non-Geometric component in the first level though. Strangely, Non-Geometric components at lower sub assembly levels are being added fine and I can query against them for release status and revision information. Any thoughts on a different way to accomplish this that will return the Non-Geometrics at the top of the assembly?

Do
ufs.Obj.CycleObjsInPart(prtParent.Tag, UFConstants.UF_component_type, compTag)
If Not compTag = tag.Null Then
Dim FoundChild As Component = NXObjectManager.Get(compTag) '<---- Errors Here
If FoundChild.Parent.DisplayName = comp.DisplayName Then
arrChild.add(FoundChild)
End If
End If
Loop Until compTag = Tag.Null

NX 7.5

I'm not sure what "comp" or "prtParent" is in your code above; so I made a small test file in NX 7.5 and ran your code with the innermost If block commented out. The code ran without errors.

What error message are you getting?

For what it's worth, here's the code I ran:

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Const undoMarkName As String = "process components"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim compTag As Tag = Tag.Null
Dim prtParent As Part = theSession.Parts.Display
Dim arrChild As New System.Collections.Generic.List(Of Assemblies.Component)

Do
theUfSession.Obj.CycleObjsInPart(prtParent.Tag, UFConstants.UF_component_type, compTag)
If Not compTag = Tag.Null Then
lw.WriteLine("compTag: " & compTag.ToString)
Dim FoundChild As Assemblies.Component = Utilities.NXObjectManager.Get(compTag)
lw.WriteLine("FoundChild.DisplayName: " & FoundChild.DisplayName)
lw.WriteLine("")
'If FoundChild.Parent.DisplayName = comp.DisplayName Then
' arrChild.Add(FoundChild)
'End If
End If
Loop Until compTag = Tag.Null

lw.Close()

End Sub

End Module

Your code is pretty much how I have mine structured.
Dim compTag as Tag = Tag.Null
Dim prtParent As Part = comp.Prototype
The error is:
Unable to cast object of type 'NXOpen.DisplayableObject' to type 'NXOpen.Assemblies.Component'.

http://imgur.com/nWB1hTu

Not sure what changed, but the code is working again at all levels.

We can blame cosmic rays or maybe the phase of the moon...