This project is read-only.

Using your library on Windows Phone 7

Apr 24, 2010 at 5:29 PM

I'm trying your library on new Windows Phone, and it works (sort of :-).

I used the following code:

<imgTool:AnimatedImage x:Name="MyMap" Source=http://mysite/test.gif />

and it works!

Instead I have a problem if I do something like:

<imgTool:AnimatedImage x:Name="MyMap" Source="{Binding Path=CurrentUrl}"  />

when I set "currentUrl" properties, I receive the followind unmanaged exception:

ImageTools.IO.UnsupportedImageFormatException was unhandled
  Message=UnsupportedImageFormatException
  StackTrace:
       at ImageTools.Image.DoLoad(Stream stream)
       at ImageTools.Image.<Load>b__12(Object x)
       at System.Threading.ThreadPool.WorkItem.doWork(Object o)
       at System.Threading.Timer.ring()

Any idea?

Coordinator
Apr 24, 2010 at 5:39 PM
Wow, havent tested it on Windows Phone yet.

Have you ever tried to download the source and step in the Source
dependency property? Do you have a demo application, perhaps for Windows
Phone and Normal Silverlight?
Apr 25, 2010 at 7:14 AM

Yes, I think that this is the best way to preceed. I just downloaded the source code, I'll keep you informed:-)

 

Apr 29, 2010 at 1:50 PM

Ok I went through the code with the debugger, and I found that _decoderTypes list for some reason is empty, so I just added the following code when the application starts.

ImageTools.IO.Decoders.AddDecoder<ImageTools.IO.Gif.GifDecoder>();

and the load works. I wonder becouse it works without binding even if I don't add this line...

 

Apr 29, 2010 at 2:15 PM

Well, I'm continuing to test the library, now the problem is that if the file does not exist, or the connection is not available etc. the library raise the followind exception:

control in xaml

<imgTool:AnimatedImage x:Name="MyMap" Source="{Binding Path=CurrentUrl}"  />

method of ImageTools.Image class:

 private void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            Load(e.Result);   <<<<<----- HERE THE EXCEPTION!

            OnDownloadCompleted(e);
        }

the exception:
System.Net.WebException was unhandled
  Message=[HttpWebRequest_WebException_RemoteServer]
Arguments:NotFound
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=3.7.50308.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer
  StackTrace:
       at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
       at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
       at System.Net.WebClient.OpenReadAsyncCallback(IAsyncResult result)
       at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
       at System.Threading.ThreadPool.WorkItem.doWork(Object o)
       at System.Threading.Timer.ring()
  InnerException: System.Net.WebException
       Message=[HttpWebRequest_WebException_RemoteServer]
Arguments:NotFound
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=3.7.50308.0&File=System.Windows.dll&Key=HttpWebRequest_WebException_RemoteServer
       StackTrace:
            at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
            at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
            at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
            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.DynamicInvokeImpl(Object[] args)
            at System.Delegate.DynamicInvoke(Object[] args)
            at System.Windows.Threading.Dispatcher.<>c__DisplayClass1.<Invoke>b__0()
            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.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)
 
well, it makes sense to raise an exception if the file is not found but I'm looking for a way to intercept the exception and show a friendly message without break the application... any idea?

Apr 29, 2010 at 2:17 PM

sorry, the correct xaml is the following:

 <imgTool:AnimatedImage x:Name="MyMap" Source="{Binding Path=CurrentUrl}"  Loaded="MyMap_Loaded" LoadingFailed="MyMap_LoadingFailed"/>


Coordinator
May 8, 2010 at 9:06 PM

Sorry, I had to do a lot. The problem with the exception is a good idea, will think about a better error message, but I think the original message is the best, because there are hundreds of differentcases, where an image cannot be loaded.