追踪StackOverFlow异常的来源?

时间:2015-07-04 19:37:51

标签: asp.net vb.net

我已经完成了所有工作,我坚持到哪里继续寻找。当向页面引入带有telerik radlistview的用户控件时,获取堆栈溢出异常。其界限如下:

Public Class Lead
Implements IDisposable

Public Sub New()
    _cxt = New DB.DBContainer
    _obj= New DB.Lead
End Sub

Public Sub New(leadEntity As DB.Lead, cxt As DB.DBContainer)
    _obj = leadEntity
    _cxt = cxt
End Sub

Public Sub New(PID As String)
    If Not IsNothing(PID) Then
        If IsNothing(_cxt) Then _cxt = New DB.DBContainer
        If IsNothing(_person) Then
            Dim tmpPID As Guid = Guid.Parse(PID)
            _obj = _cxt.Leads.Find(tmpPID)
        End If
    End If
End Sub

Private _cxt As DB.DBContainer
Private _obj As DB.Lead
Protected Overridable Overloads Sub Dispose(disposing As Boolean)
    If disposing Then
        If Not IsNothing(_cxt) Then
            _cxt.SaveChanges()
            _cxt.Dispose()
            _obj = Nothing
        End If
    End If
End Sub
Public Overloads Sub Dispose() Implements IDisposable.Dispose
    Dispose(True)
    GC.SuppressFinalize(Me)
End Sub 
Public ReadOnly Property TimeLine As IEnumerable(Of BI.Timeline)
    Get
        If _obj.LeadLogs.Count > 0 Then
            Return _obj.TimelineLogs.Select(Function(p) New BI.Timeline(p, _cxt))
        End If
        Return Nothing
    End Get
End Property

以上查询返回62条记录。

我已将Timeline类简化为几乎没有:

Public Class Timeline
Implements IDisposable
Public Sub New()
    _cxt = New DB.DBContainer
    _log = New DB.LeadLog
End Sub

Public Sub New(LogEntity As DB.LeadLog, cxt As DB.DBContainer)
    _log = LogEntity
    _cxt = cxt
End Sub

Public Sub New(ID As String)
    If Not IsNothing(ID) Then
        If IsNothing(_cxt) Then _cxt = New DB.DBContainer
        If IsNothing(_log) Then
            Dim tmpID As Guid = Guid.Parse(ID)
            _log = _cxt.LeadLogs.Find(tmpID)
        End If
    End If
End Sub

Private _cxt As DB.DBContainer
Private _log As DB.LeadLog
Protected Overridable Overloads Sub Dispose(disposing As Boolean)
    If disposing Then
        If Not IsNothing(_cxt) Then
            _cxt.SaveChanges()
            _cxt.Dispose()
            If Not IsNothing(_log) Then _log = Nothing
        End If
    End If
End Sub
Public Overloads Sub Dispose() Implements IDisposable.Dispose
    Dispose(True)
    GC.SuppressFinalize(Me)
End Sub

Public ReadOnly Property ID As Guid
    Get
        Return _log.Id
    End Get
End Property

下图是异常的调用堆栈。值得注意的是我可以加载调用页面,但是当我点击刷新或重新加载页面时,我遇到了麻烦。

如果我修改

 Return _obj.TimelineLogs.Select(Function(p) New BI.Timeline(p, _cxt))

到一个小于预期记录数的值,期望为62

 Return _obj.TimelineLogs.take(61).Select(Function(p) New BI.Timeline(p, _cxt))

我不再收到溢出异常,而且需要的时间少于我期望它返回的行数。

1

这看起来很奇怪 enter image description here

0 个答案:

没有答案