CA2000 is still flagged when a reference is passed in the constructor of another object and that other object does not go out of scope. See the following code example.
Public Shared ReadOnly Property Current() As HttpSessionState
Get
If (HttpContext.Current Is Nothing) Then
Dim writer As System.IO.StringWriter = Nothing
Try
writer = New System.IO.StringWriter(CultureInfo.InvariantCulture)
HttpContext.Current = New HttpContext(New HttpRequest("", "http://localhost/", ""), New HttpResponse(writer))
SessionStateUtility.AddHttpSessionStateToContext(HttpContext.Current, New HttpSessionStateContainer("", New SessionStateItemCollection(),New HttpStaticObjectsCollection(), 20000, True, HttpCookieMode.UseCookies, SessionStateMode.Off, False))
Catch
If writer IsNot Nothing Then writer.Dispose()
Throw
End Try
End If
Return HttpContext.Current.Session
End Get
End Property