WP7: InvalidOperationException while trying out GIFs

Mar 12, 2012 at 5:23 PM

While trying to use the Gif decoder in Wp7, I kept getting an unknown exception out of the DLL.

I downloaded and compiled the source code to see what raised the error, and this time the debugger highlighted this (in "ExtendedImage.cs")

 

  private void LoadAsync(Stream stream)
        {
            Contract.Requires(stream != null);
            Contract.Requires<InvalidOperationException>(stream.CanSeek); // <-- THIS
             ...

 

With the exception "InvalidOperationException was unhandled".
If I comment it out it runs, but the same message appears in the console and doesn't display any images. 

The detailed error:

 

System.InvalidOperationException was unhandled
  Message=InvalidOperationException
  StackTrace:
       at System.Diagnostics.Contracts.Contract.Requires[TException](Boolean condition)
       at ImageTools.ExtendedImage.LoadAsync(Stream stream)
       at ImageTools.ExtendedImage.webClient_OpenReadCompleted(Object sender, OpenReadCompletedEventArgs e)
       at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
       at System.Net.WebClient.OpenReadOperationCompleted(Object arg)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at System.Delegate.DynamicInvokeOne(Object[] args)
       at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
       at System.Delegate.DynamicInvoke(Object[] args)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
       at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
       at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
       at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
       at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

I don't have source access to the images, naturally, or else I'd have used Jpegs :-P

Any tips, directions, ideas?

Thanks in advance.