The remote server returned an error: NotFound.

Feb 26, 2015 at 6:18 PM
Edited Mar 12, 2015 at 2:48 PM
Hello. After using imagetools I found new crash callstack in app statistics. Unfortunately, I don't know when and why it's happening. Here is my xaml
<imagetools:AnimatedImage Name="ImgGif" />
and code-behind
if ((e.NewValue as Uri).AbsoluteUri.EndsWith(".gif"))
{
ImgGif.Source = new ImageTools.ExtendedImage() { UriSource = (e.NewValue as Uri) };
}
Uri can be invalid (but with .gif ending). I tried different invalid uris, but still not reproduced this issue.

callstack:
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at System.Net.OpenReadCompletedEventArgs.get_Result()
at ImageTools.ExtendedImage.webClient_OpenReadCompleted(Object sender, OpenReadCompletedEventArgs e)
at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
at System.Net.WebClient.OpenReadOperationCompleted(Object arg)
Seems like problem is something here (ExtendedImage.cs)
private void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    try
    {
        if (e.Error == null)
        {
            Stream remoteStream = e.Result

            if (remoteStream != null)
            {
                LoadAsync(remoteStream);
            }
        }
        else
        {
            OnLoadingFailed(new UnhandledExceptionEventArgs(e.Error, false));
        }

        OnDownloadCompleted(e);
    }
    catch (WebException ex)
    {
        OnLoadingFailed(new UnhandledExceptionEventArgs(ex, false));
    }
}
Stream remoteStream = e.Result will throw System.InvalidOperationException but threse is no catch for that. I have added addtitional catch and some logging. If I'll find out something interesting I'll update this post.