Setting the source for AnimatedImage in the code behind

Jan 8, 2011 at 4:51 AM

On WP7,  i am trying to set the source for the animatedImage from the code behind. I have been struggling with this and tried number of things and it is causing me the below exceptions.I have initialized the GifDecode in my Mainpage constructor as Decoders.AddDecoder<GifDecoder>();

and have the following dlls incliuded ICSharpCode.., imageTools, ImageTools.Controls, ImageTools.Filtering, ImageTools.IO.Gif, ImageTools.Utils and PhoneCodeContractsAssemblies

XAML:


                    <it:AnimatedImage x:Name="gifImageo" Width="690" Height="355" Margin="10,40,0,0" Source="{Binding ImageUrl}" VerticalAlignment="Top" Visibility="Collapsed" LoadingFailed="gifImageo_LoadingFailed">
                            <it:AnimatedImage.RenderTransform>
                                <ScaleTransform x:Name="GifImageScaling" ScaleX="1" ScaleY="1" />
                            </it:AnimatedImage.RenderTransform>
                    
                                
                        </it:AnimatedImage>


Code Behind:
                       ExtendedImage img = new ExtendedImage();
                        img.UriSource = new Uri(itemList.ElementAt(0).ImageUrl, UriKind.RelativeOrAbsolute);
                        this.gifImageo.Source = img;


Exception:

System.TypeInitializationException was unhandled
  Message=The type initializer for 'ImageTools' threw an exception.
  TypeName=ImageTools.ImageExtensions
  StackTrace:
       at ImageTools.Controls.AnimatedImage.AssignImage(ExtendedImage image)
       at ImageTools.Controls.AnimatedImage.LoadImage(ExtendedImage image)
       at ImageTools.Controls.AnimatedImage.<>c__DisplayClass9.<image_LoadingCompleted>b__8()
       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)

Coordinator
Jan 8, 2011 at 8:48 AM
You should also include the png encoder because the utils library is
referencing it as default encoder / decoder.