views:

109

answers:

2

I have a program that uses Lucene.net in ASP.NET (VB.NET), when you search a term, results are stored in the Lucene.net data structure "hits".

I want to read out the hits into an data structure and work with them, after that I display them in a DataGrid.

By searching a term with a lot of results, often (but not always) there is an error by following code :

For i = 0 To results - 1 Step 1
    Try
        Dim tmpobj As New object_hit(( _
            hits.Doc(i).Get("title") + _
            hits.Doc(i).Get("doc_typ")), _
            hits.Doc(i).Get("pfad"), _
            hits.Doc(i).Get("last_change"), _
            hits.Doc(i).Get("doc_typ"), _
            CStr(hits.Score(i)))    
        list_of_results.Add(tmpobj) 'works'
    Catch
        meldung.Text = "Stackoverflow- zuviele Ergebnisse "
        myexception = True
    End Try

I checked the server; it's a dwh server and has no problems to execute the program.

At first I used a ReDim Array, but now I use a List(Of T). I heard that should solve the problem, but it doesn't - now I'm very confused and don't know what to do- can someone help me please?

A: 

Change the Catch block so that you actually can see what is happening here:

Catch ex as Exception
    meldung.Text = ex.Message ' or ex.ToString() to see full details '
    throw
End Try

You are probably not getting a StackOverflowException here.

0xA3
@abatishchev: I don't mind the edit, but a comment in VB is not required to be closed with an apostrophe.
0xA3
@0xA3 That's a good point about the language; however, the syntax highlighting on SO will make the color of all subsequent code to be the same color as a comment/string if you don't "close" the VB comment with an additional quote. The only purpose of adding an additional quote is to increase readability on SO.
Ben McCormack
@0xA3: Right. But closing mark fixes broken support of VB syntax in Google syntax highlighting mechanism used on SO. Without mark, I don't know why and I guess nobody except author, remained code will be colored as a comment. Try and you will see
abatishchev
To add to @Ben's comment, compare the edits to see the color difference that occurs.
Ahmad Mageed
@Ben, @Ahmand, thanks!)
abatishchev
A: 

hello, my browser crashed, so i have to write as an guest : < sorry.

i tried that:

Exception of type 'System.OutOfMemoryException' was thrown.

now i have an correct for loop, with only one line of code in it

list_of_results.Add(New object_hit((hits.Doc(i).Get("title") + hits.Doc(i).Get("doc_typ")), hits.Doc(i).Get("pfad"), hits.Doc(i).Get("last_change"), hits.Doc(i).Get("doc_typ"), CStr(hits.Score(i)))) 

so what happened? (the server is an dwh server, it should make it ...)

thanks

tim