プロジェクトでコード分析を実行しようとすると、コードのこの部分でエラーが発生します。
//コード
Private Sub SaveMaterialStatus(ByVal status As String)
Dim cSMaterialInput As CSMaterialInput = Nothing
Try
If ViewState("CSInput") IsNot Nothing Then
'Create a new transaction
cSMaterialInput = New CSMaterialInput
cSMaterialInput = ViewState("CSInput")
cSMaterialInput.CSStatus = status
CSMaterialInputMethods.SaveToDatabase(cSMaterialInput, Environment.UserName, Environment.MachineName)
End If
Catch ex As Exception
Throw
Finally
If cSMaterialInput IsNot Nothing Then cSMaterialInput.Dispose()
End Try
End Sub
詳細なエラー:
CA2000 Dispose objects before losing scope In method 'ShowSummary.SaveMaterialStatus(String)', call System.IDisposable.Dispose on object 'cSMaterialInput' before all references to it are out of scope. xxxx.CostingTool.Presentation ShowSummary.aspx.vb 790
どこが間違っていますか??