I have been asked to extract an email address list from a GroupWise 6
system that contains approximately 190 domains and 15,000 users. I am
using the GroupWise Administative object because I need to include in the
address list users with a visibility of 'None'. Users with a visibility
of 'None' do not appear in the address list generated by the GroupWise API
NLM or the GroupWise Object API control.

My VB.NET application appears to finish normally: the number of domains
found is correct but the number of users is not even close - only 2066.
Then an error message is displayed:

The instruction at "0x03d059bf" referenced memory at "0x00000004". The
memory could not be read. Click OK to terminate the program.

Can anyone tell me if there is a known problem with the GW Admin object or
perhaps I have used sloppy code (A copy of my code is given below). If
the former is true then can you recommend an alternative object?

Many thanks in advance,


Code with error trapping removed for clarity:

Private gobjGWAdmin As AdminTypeLibrary.System
Private glngUserCount As Long
Private Const cstrPrimaryDomainPath As String = "\ServerVolumeGWPrimary"

Public Function Main() As Integer

gobjGWAdmin = New AdminTypeLibrary.System()

Call DomainLoop

colDomains = Nothing
iterDomains = Nothing
objDomain = Nothing

End Function

Private Sub DomainLoop()

Dim colDomains As AdminTypeLibrary.Domains ' Collection of domains.
Dim iterDomains As AdminTypeLibrary.DomainsIterator ' Domain iterator
Dim objDomain As AdminTypeLibrary.Domain ' Domain object.
Dim strDomainList() As String
Dim intDomainIdx As Integer

On Error Resume Next

colDomains = gobjGWAdmin.Domains
iterDomains = colDomains.CreateIterator
objDOmain = iterDomains.Next()

intDomainIdx = 0
While (objDOmain Is Nothing) = False
ReDim Preserve strDomainList(intDomainIdx)
strDomainList(intDomainIdx) = objDOmain.Name
Call UserLoop(objDomain)
intDomainIdx = intDomainIdx + 1
objDOmain = iterDomains.Next
End While
MessageBox.Show("Number of domains: " & intDomainIdx.ToString &
vbCrLf & vbCrLf & _
"Number of users: " & gintUserCount.ToString)

End Sub

Private Sub UserLoop(ByVal objDomain As AdminTypeLibrary.Domain)

Dim colUsers As AdminTypeLibrary.Users ' Collection of users.
Dim iterUsers As AdminTypeLibrary.UsersIterator ' User iterator object.
Dim objUser As AdminTypeLibrary.User ' User object.
Dim strUserList() As String
Dim intUserIdx As Integer

On Error Resume Next

colUsers = objDomain.Users
iterUsers = colUsers.CreateIterator
If Err.Number <> 0 Then
If Err.Number = 91 Then
'No users in the domain.
MessageBox.Show("An unexpected error was raised ...")
End If
GoTo Cleanup
End If

objUser = iterUsers.Next()

intUserIdx = 0
While (objUser Is Nothing) = False
ReDim Preserve strUserList(intUserIdx)
strUserList(intUserIdx) = objUser.Surname
intUserIdx += 1
glngUserCount += 1
objUser = iterUsers.Next
End While
colUsers = Nothing
iterUsers = Nothing
objUser = Nothing
objDomain = Nothing

End Sub