用户代码未处理null引用异常

时间:2010-02-19 01:43:37

标签: vb.net exception-handling

先生,我在vs2005中开发了以下代码,现在我只是在我的新项目@ vs 2008中使用这个模块。               但是这个错误被提出了。我无法解决这个问题...

Private Sub DataAccess()

    Dim errHandle As New ErrorHandler
    Dim lobjCommon As New eCopsCommonFunctions
    Try
        AccessCodeDrplst.DataSource = CType(lobjCommon.gfuncGetAllEnrollmentSource(), DataSet)
        AccessCodeDrplst.DataValueField = "DataAccessCode"
        AccessCodeDrplst.DataTextField = "DataAccessDesc"
        AccessCodeDrplst.DataBind()
        'lstEnrollmentSourceCode.DataValueField = "EnrollmentSourceCode"
        'lstEnrollmentSourceCode.DataTextField = "EnrollmentSourceDesc"
        'lstEnrollmentSourceCode.DataBind()
        '"Beneficiary Election" is pre selected as default value. By pals on Oct 24th 2007
        'lstEnrollmentSourceCode.SelectedValue = "B"
        'lstEnrollmentSourceCode.Items.Insert(0, New ListItem("Select", "0"))
    Catch ex As Exception
        errHandle.gProcHandleErrors(ex, Session("MemberID"), "SPStatus.aspx.vb, gprocFillSEPCode")
        Throw ex
    Finally
        lobjCommon = Nothing


        ///here the error occurs as 'NullException was unhandle by the user code'
        errHandle = Nothing
    End Try
End Sub

1 个答案:

答案 0 :(得分:0)

不是由于

 Throw ex

在“catch”区块内划线?

(格式化有点出局)

BTW,不要“抛出” - 只是“抛出”(阅读异常处理技术)