例外:尝试读取或写入受保护的内存

时间:2015-08-25 16:27:03

标签: asp.net .net vb.net session

我的项目包含对SetSession的调用ManyTime SomeTime它的崩溃。请任何人都可以帮助我。

这里的部分代码:

public Function SetSession(sSessionName As String) As Boolean
Dim intCount As Integer
'Call Refresh
SetSession = False
Dim oSessions As ExtaSessions = Nothing
Dim oSession As ExtraSession = Nothing
moSession = Nothing
oSessions=TryCast(moSystem.Sessions,ExtraSessions)
moSession=TryCast(oSessions.Item(sSessionName),ExtraSession)'=> Crashing in this line
If Information.Err().Number <> 0 Then
For intcount = 1 To  oSessions.Count
oSession = TryCast(oSessions.Item(intCount), ExtraSession)
if oSession.Name = sSessionName then
moSession = oSession
Exit for
End if
NExt
End if
if moSession is Nothing then
Exit Function End If
SetSession = True
End Function

以下附件PrintScreen for Exception

enter image description here

0 个答案:

没有答案