FlickrNet Crashes With - Arithmetic operation resulted in an overflow.

Topics: Developer Forum
Nov 5, 2013 at 1:37 AM
I have written a Flickr Screen Saver that I have used for almost a year now on a few computers. On one computer, it would not pull down new photos from Flickr anymore even though the application worked fine on the other computers.

I have narrowed down the code to the bare essentials where it crashes on that one problem computer (runs Windows 7 - 64 Bit - Fully patched and updated and scanned for viruses). I cannot understand why this crashes all of a sudden on that one computer but runs fine on the rest.

I substituted the Flickr API Key and Photo Set ID in the code for the example.
Imports FlickrNet
Public Class frmMain
    Private Sub cmdExecute_Click(sender As System.Object, e As System.EventArgs) Handles cmdExecute.Click
        Try
            txtOutput.Text = txtOutput.Text & vbCrLf & "Debug Position - 1"
            Dim FlickrConnectionObject As Flickr = New Flickr("{Flickr API Key Goes Here}")
            txtOutput.Text = txtOutput.Text & vbCrLf & "Debug Position - 2"
            Dim FlickrSetPageResults As PhotosetPhotoCollection = FlickrConnectionObject.PhotosetsGetPhotos("{Photo Set ID Goes Here}", 1, 5)
            txtOutput.Text = txtOutput.Text & vbCrLf & "Debug Position - 3"
        Catch ex As Exception
            txtOutput.Text = txtOutput.Text & vbCrLf & vbCrLf & "Caught Error" & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace
        End Try
    End Sub
End Class
Here is the output on that one bad computer (works great on all the others)
As you can see the error is caused by:

Dim FlickrSetPageResults As PhotosetPhotoCollection = FlickrConnectionObject.PhotosetsGetPhotos("{Photo Set ID Goes Here}", 1, 5)

But again, it works on all the other computers (and worked on this one too until recently.
Debug Position - 1
Debug Position - 2

Caught Error

Arithmetic operation resulted in an overflow.

   at FlickrNet.UtilityMethods.ReadString(Stream s)
   at FlickrNet.PersistentCache.Load(Stream s)
   at FlickrNet.PersistentCache.Refresh()
   at FlickrNet.PersistentCache.Get(String key, TimeSpan maxAge, Boolean removeIfExpired)
   at FlickrNet.Flickr.GetResponse[T](Dictionary`2 parameters, TimeSpan cacheTimeout)
   at FlickrNet.Flickr.PhotosetsGetPhotos(String photosetId, PhotoSearchExtras extras, PrivacyFilter privacyFilter, Int32 page, Int32 perPage, MediaType media)
   at FlickrNet.Flickr.PhotosetsGetPhotos(String photosetId, Int32 page, Int32 perPage)
   at TestFlickrNet.frmMain.cmdExecute_Click(Object sender, EventArgs e) in D:\Synchronized Data\Miscellaneous Files\Synchronized Documents\Coding\TestFlickrNet\TestFlickrNet\frmMain.vb:line 8
I am TRULY stumped here and have no idea what is going on!

Please Help!

Jean-Marie Vaneskahian
jean@vaneskahian.com
Coordinator
Nov 6, 2013 at 2:35 PM
Sounds like the cache on that machine is corrupt for some reason.
Nov 7, 2013 at 3:32 PM
Thanks Sam, I appreciate the help. I will spend some time researching how to possibly fix this.

Just an FYI, I did try writing a test function that would go out to Flickr and make calls to the REST API and parse the returned XML from that computer and that worked. It must me some specific function in the FlickrNet library that the one computer has a problem with.

Thanks again.

Jean-Marie Vaneskahian
jean@vaneskahian.com
Coordinator
Nov 9, 2013 at 7:12 AM
I'd recommend trying to clear the cache on that machine, either call FlushCache on a Flickr instance (the cache is shared across all Flickr instances) or find the location (hidden in you app data directory somewhere) and delete it manually.

Sam