【问题标题】:null reference exception was unhandled by user code用户代码未处理空引用异常
【发布时间】:2010-02-19 01:43:37
【问题描述】:

先生,我在 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

【问题讨论】:

  • 再次检查您发布的 finally 块中的代码是否与您的程序中的代码实际匹配。
  • user238319 - 问题解决了吗?

标签: vb.net exception-handling


【解决方案1】:

难道不是因为

 Throw ex

“catch”块内的行?

(格式有点不对)

顺便说一句,不要“throw ex”——只是“throw”(阅读异常处理技术)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    相关资源
    最近更新 更多