variable used before it has been assigned a value
When compiling the Data tier classes for the Accounts module, I am warned that a null reference exception could occur at runtime because the code uses a variable before it has been assigned a value. The classes "User", "Role" and "Permission" all contain this warning.
Here is an exmaple of a function that makes this warning:
Public Function GetAllPermissions() As DataSet
Dim permissions As DataSet
Try
permissions = RunProcedure( _
"AccountsGetAllPermissions", New IDataParameter() {}, "Permissions")
Return permissions
Finally
If Not permissions Is Nothing Then
permissions.Dispose()
End If
End Try
End Function
The code will still compile, as it is a warning, not an error, but for my peace of mind, is there a better way to write those fragments of code so that this doesn't happen?
|