Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collection is removed from memory after a while
Message
 
 
À
15/11/2013 13:23:30
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588067
Message ID:
01588071
Vues:
30
>Here is one item that went ok on test but caused an unexpected situation in production. The following is a method which checks a collection for the presence of an item:
>
>
>    ' Return True or False if an image is loaded in memory
>    ' expC1 Name
>    Public Function IsImageInMemory(ByVal tcName As String) As Boolean
>        Dim lcName As String = ""
>        Dim lcNameToSearch As String = ""
>        Dim llFound As Boolean = False
>        Dim loObject As Object
>
>        ' Initialization
>        lcNameToSearch = UCase(Trim(tcName))
>
>        ' For each image in the collection
>        For Each loObject In oProcess.oApp.oImage
>
>            ' Initialization
>            lcName = loObject(1)
>
>            ' If we have found it
>            If UCase(lcName) = lcNameToSearch Then
>                llFound = True
>
>                ' Initialization
>                nWidth = loObject(2)
>                nHeight = loObject(3)
>
>                Exit For
>            End If
>
>        Next
>
>        Return llFound
>    End Function
>
>
>This is executed hundreds of thousands of times per hour. After several hours in production with this new version, I have found out that the oProcess.oApp.oImage collection is not acting as it should. It returns the message "Object reference not set to an instance of an object." at this level:
>
>at Microsoft.VisualBasic.Collection.GetEnumerator()
> at Framework.ProcessWeb.IsImageInMemory(String tcName)
>
>I thought using a collection would be safe enough to check for in memory content for several items. Should I have used an array instead?

It is a strange code. What is loObject(1)? Shouldn't you use loObject.Name instead and other properties?

Also, in C# you will need to give a type to the loObject in this code. I don't see a type in your code.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform