Visible layers in view

Hi, I have tried to make a journal to list all visible layers in a specific model view.
But I struggle to get the code correct. Could you help me?
I think GetVisibilitiesInView should be the method to use but obviously the syntax isn’t correct.

Option Strict Off
Imports System
Imports NXOpen

Module Module1
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim pmiNotesView As Integer

Sub Main()
Dim views As ModelingViewCollection
Dim layersInView As New List(Of Layer.StateInfo)
views = workPart.ModelingViews
lw.Open()

For Each view As ModelingView In views
If view.Name <> "Front" Then
Else
lw.WriteLine("Front view exist")
layersInView = theSession.Parts.Work.Layers.GetVisibilitiesInView(view)
Exit For
End If
Next

For Each temp As Layer.StateInfo In layersInView
lw.WriteLine(temp.ToString)
Next

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'-------------------------------
End Function
End Module

Try the following:

Option Strict Off
Imports System
Imports NXOpen

Module Module183
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim pmiNotesView As Integer

Sub Main()
Dim views As ModelingViewCollection
Dim layersInView() As Layer.StateInfo
views = workPart.ModelingViews
lw.Open()

For Each view As ModelingView In views
If view.Name <> "Front" Then
Else
lw.WriteLine("Front view exist")
theSession.Parts.Work.Layers.GetVisibilitiesInView(view, layersInView)
Exit For
End If
Next

For Each temp As Layer.StateInfo In layersInView
lw.WriteLine(temp.ToString)
Next

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module

Incredibly fast response and it works.
Thank you very much!

Best Regards
Gunnar