Hi all:
I have created a vb.net service that watches a directory and when an
image is placed in the directory a thumbnail of the image is created. The
problem I am having is a System.OutOfMemoryException: Out of memory. This
occurs after 1 or 2 thumbnails have been created. It looks as if the dispose
method is not working. I have created the thumbnails in a couple of different
ways but still get an error Invalid parameter used. After 1 or 2 thumbnails
have been created.
This problem does not exist when the service is on an xp machine. It
exists when placed on win 2000 server.
Here is the thumbnail function:
Public Function makeThumb(ByVal filePath As String, ByVal strThumbPath As
String, ByVal numArrayElement As Integer) As Boolean
Dim thePtr As System.IntPtr
Dim ObjTemp, testObj As System.Drawing.Image
Try
testObj = testObj.FromFile(filePath) '<---- error occurs here
ObjTemp = testObj.GetThumbnailImage(100, 100, AddressOf
ThumbNailAbort, thePtr)
ObjTemp.Save(strThumbPath, Drawing.Imaging.ImageFormat.Jpeg)
testObj.Dispose()
ObjTemp.Dispose()
'Force Garbage collection
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
makeThumb = True
Catch ex As Exception
makeThumb = False
LogException("ServiceMedia Log", ex, EventLogEntryType.Error)
End Try
End Function
Any help would be appriciated.
Thanks