Domino Com via .Net 2.0 : PANIC: m_cRef below 0

We are dynamically populating a .Net treeview control with entries from a Notes ViewNavigator by passing in the Position value of the TreeNode being populated in order to retreive the Sibling values. Intermittently the call to Domino.NotesViewNavigator.GetCurrent after the SetPos Method generates an .Net AccessViolation with a matching crash in the Notes console log:

(207-28 [207]) GET_COLLATION: 15 ms. [12+14=26]

(208-28 [208]) READ_ENTRIES(REPCC256F4A:0003E562-NT00000636): 16 ms. [76+166=242]

Thread=[0158:0005-0700]

Stack base=0x0012D678, Stack size = -576 bytes

PANIC: m_cRef below 0

Below is a stripped down version of the function (Exception handling and object cleanup removed.)

Function GetFolderTreeItems(ByVal parentKeyASNavigatorPosition As String) As Collection



    Dim myTreeBrowserDemoFolder As New TreeBrowserDemoFolderItem

    Dim myCollection As New Collection

    Dim myTreeBrowserDemoFolderTreeItem As TreeBrowserDemoFolderTreeItem

    Dim myViewEntry As Domino.NotesViewEntry

    Dim CurrentEntry As Domino.NotesViewEntry

    Dim myViewEntryParent As Object = Nothing



    Dim myViewNavOpenFolders As Domino.NotesViewNavigator '(Class var)





        'Get a handle to the first view entry

        If parentKey = "" Then

            myViewEntry = myViewNavOpenFolders.GetFirst

        Else



                myViewNavOpenFolders.GotoPos(parentKey, ".")

                myViewEntryParent = myViewNavOpenFolders.GetCurrent 'EAccessViolation



            If Not (myViewEntryParent Is Nothing) Then

                myViewEntry = myViewNavOpenFolders.GetChild(myViewEntryParent)

            End If



        End If





        While Not (myViewEntry Is Nothing)



            myTreeBrowserDemoFolderTreeItem = New TreeBrowserDemoFolderTreeItem



            If myViewEntry.IsCategory = True Then

                myTreeBrowserDemoFolderTreeItem.DisplayName = myViewEntry.ColumnValues(0)

                myTreeBrowserDemoFolderTreeItem.Type = "Category"

                myTreeBrowserDemoFolderTreeItem.NoChildren = myViewEntry.ChildCount

                myTreeBrowserDemoFolderTreeItem.FolderID = myViewEntry.GetPosition(".")

            Else



                myTreeBrowserDemoFolderTreeItem.FolderID = myViewEntry.ColumnValues(2)

                myTreeBrowserDemoFolderTreeItem.FolderName = myViewEntry.ColumnValues(3)

                myTreeBrowserDemoFolderTreeItem.Type = "Folder"

            End If



            myCollection.Add(myTreeBrowserDemoFolderTreeItem)



            CurrentEntry = myViewEntry

            myViewEntry = myViewNavOpenFolders.GetNextSibling(CurrentEntry)



        End While





    Return myCollection



End Function

Thoughts? Advice? Our next step is to apply all maintenance and fix packs to the Server.

The Database being interrogated via the primary view can be upto 50GB in size. The Domino Server is running in a 1GB Windows XP virtual machine on a Windows 2003 server with a standard server install and untweaked Notes.ini and there is no other load other than the developer.

Subject: Domino Com via .Net 2.0 : PANIC: m_cRef below 0

Where are you instantiating myViewNavOpenFolders?

e.g.:

CreateViewNav

CreateViewNavFrom

CreateViewNavFromCategory

CreateViewNavFromChildren

CreateViewNavFromDescendants

Also, where is parentKey defined?

Subject: RE: Domino Com via .Net 2.0 : PANIC: m_cRef below 0

myViewVavOpenFolders is a class member variable for a general purpose wrapper around these notes methods. Thats where I have commented 'Class var to show that its actually global to this method

It is created from a NotesView using CreateViewNav method.

        If myViewNavOpenFolders Is Nothing Then

            Dim tmpView As Domino.NotesView

            tmpView = myDbLib.GetView("(OpenFolders)")

            If Not (tmpView Is Nothing) Then

                myViewNavOpenFolders = tmpView.CreateViewNav

            Else

                'error

                Return Nothing

            End If

        End If

Parent Key is retrieved and stored in the TreViewUI and is retrieved originally by a call to

myTreeBrowserDemoFolderTreeItem.FolderID = myViewEntry.GetPosition(“.”)

as in the above code. So the Node being expanded passes back the position decimal in order to get the children.

The EaccessViolation Exception states :

“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”

at Domino.NotesViewNavigatorClass.GetCurrent()

at DocOne.FolderManager.DataLibrary.GetFolderTreeItems(String parentKey) in C:\Documents and Settings\localadmin\My Documents\Visual Studio 2005\Projects\Classes\DataClass.vb:line 189"

the PANIC is not invariable sometimes the crash has no correlate in the console log. This error condition is variable and intermittent i.e it appears to be independent of the data.

Its something I guess with reference counting, dereferencing, memory, stale COM objects etc. Upgrading the server to FP2 has not changed anything

Thanks for your interest

Subject: RE: Domino Com via .Net 2.0 : PANIC: m_cRef below 0

I haven’t looked at your code in detail, but there was a leak with COM objects that worked with arrays of strings if I recall that was fixed in 7.0.3 and 7.0.2FP3. You should look at those (probably 7.0.2FP3 since that’s closest to what you’ve got).