G
Guest
Hi,
I am writing a small app to check for the existence of files on remote
workstations. GUI is great, but when I click to check the workstations, the
following error is displayed. The point of failure is highlighted within the
code sample. I beleive the problem is to do with the arraylist within the
structure, but have no proof or idea of how to fix the problem. I have tried
changing the structure into classes, writing a text string instead of an
InstCheck instance, but always get the same error.
Any help would be appreciated.
Many thanks,
Martin
ERROR MESSAGE :
An unhandled exception of type 'System.NullReferenceException' occurred in
StoreWorkstationSoftwareInstallationChecker.exe
Additional information: Object reference not set to an instance of an object.
CODE SAMPLE :
Public Structure InstCheck
Public Application As String
Public Installed As Boolean
End Structure
Private Structure Results
Public Client As String
Public Installations As ArrayList
Private Function AllOK() As Boolean
Dim ReturnString As Boolean = True
Dim Install As InstCheck
For Each Install In Installations
If Not Install.Installed Then
ReturnString = False
End If
Next
Return ReturnString
End Function
Public Overrides Function ToString() As String
Dim ReturnString As String
ReturnString = Client & " " & AllOK()
Return ReturnString
End Function
Public Sub AddApp(ByVal App As InstCheck)
Dim temp As Integer
temp = Installations.Add(App) ß-- ERROR HERE
End Sub
End Structure
Private Sub ibCheckClients_Click() Handles ibCheckClients.Click
Dim ClientToCheck As String
Dim AppFile As String
Dim AppPath As String
Dim ClientPath As String
Dim ClientResult As Results
For Each ClientToCheck In lbClientsToCheck.Items
ClientResult.Client = ClientToCheck
ClientPath = "\\" & ClientToCheck & "\c$\StrSupport\SW_INSTALLED\"
For Each AppFile In lbFilesToCheck.Items
Dim AppResult As InstCheck
AppResult.Application = AppFile
AppPath = ClientPath & AppFile
If File.Exists(AppPath) Then
AppResult.Installed = True
Else
AppResult.Installed = False
End If
ClientResult.AddApp(AppResult)
Next
lbResults.Items.Add(ClientResult)
Next
End Sub
I am writing a small app to check for the existence of files on remote
workstations. GUI is great, but when I click to check the workstations, the
following error is displayed. The point of failure is highlighted within the
code sample. I beleive the problem is to do with the arraylist within the
structure, but have no proof or idea of how to fix the problem. I have tried
changing the structure into classes, writing a text string instead of an
InstCheck instance, but always get the same error.
Any help would be appreciated.
Many thanks,
Martin
ERROR MESSAGE :
An unhandled exception of type 'System.NullReferenceException' occurred in
StoreWorkstationSoftwareInstallationChecker.exe
Additional information: Object reference not set to an instance of an object.
CODE SAMPLE :
Public Structure InstCheck
Public Application As String
Public Installed As Boolean
End Structure
Private Structure Results
Public Client As String
Public Installations As ArrayList
Private Function AllOK() As Boolean
Dim ReturnString As Boolean = True
Dim Install As InstCheck
For Each Install In Installations
If Not Install.Installed Then
ReturnString = False
End If
Next
Return ReturnString
End Function
Public Overrides Function ToString() As String
Dim ReturnString As String
ReturnString = Client & " " & AllOK()
Return ReturnString
End Function
Public Sub AddApp(ByVal App As InstCheck)
Dim temp As Integer
temp = Installations.Add(App) ß-- ERROR HERE
End Sub
End Structure
Private Sub ibCheckClients_Click() Handles ibCheckClients.Click
Dim ClientToCheck As String
Dim AppFile As String
Dim AppPath As String
Dim ClientPath As String
Dim ClientResult As Results
For Each ClientToCheck In lbClientsToCheck.Items
ClientResult.Client = ClientToCheck
ClientPath = "\\" & ClientToCheck & "\c$\StrSupport\SW_INSTALLED\"
For Each AppFile In lbFilesToCheck.Items
Dim AppResult As InstCheck
AppResult.Application = AppFile
AppPath = ClientPath & AppFile
If File.Exists(AppPath) Then
AppResult.Installed = True
Else
AppResult.Installed = False
End If
ClientResult.AddApp(AppResult)
Next
lbResults.Items.Add(ClientResult)
Next
End Sub