This project has moved. For the latest updates, please go here.
2
Vote

FormatException when searching movie with Api Configuration in french

description

Hi,

I work with the Windows Phone version (0.5) and when i use the method SearchMovie() to get a movie with the Api configured with the french language (Tmdb api = new Tmdb(myKey,"fr");), I have a FormatException corresponding, apparently, to DateTime.

Here is the Stack:

at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider)
at System.Convert.ToDouble(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDouble(IFormatProvider provider)
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at RestSharp.Extensions.ReflectionExtensions.ChangeType(Object source, Type newType, CultureInfo culture)
at RestSharp.Deserializers.JsonDeserializer.Map(Object target, IDictionary2 data)
at RestSharp.Deserializers.JsonDeserializer.CreateAndMap(Type type, Object element)
at RestSharp.Deserializers.JsonDeserializer.BuildList(Type type, Object parent)
at RestSharp.Deserializers.JsonDeserializer.Map(Object target, IDictionary
2 data)
at RestSharp.Deserializers.JsonDeserializer.Deserialize[T](IRestResponse response)
at WatTmdb.V3.WatJsonDeserializer.Deserialize[T](IRestResponse response)
at RestSharp.RestClient.Deserialize[T](IRestRequest request, IRestResponse raw)
at RestSharp.RestClient.<>c__DisplayClass2a1.b__29(IRestResponse response, RestRequestAsyncHandle asyncHandle)
at RestSharp.RestClient.ProcessResponse(HttpResponse httpResponse, RestRequestAsyncHandle asyncHandle, Action
2 callback)
at RestSharp.RestClient.<>c__DisplayClass23.b__20(HttpResponse r)
at RestSharp.RestClient.<>c__DisplayClass25.<>c__DisplayClass27.b__22(Object s)
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)

Thanks

file attachments

comments

watway wrote Nov 8, 2012 at 6:03 AM

Hi,

I've been unable to repeat the problem. It's possible it might be specific to the search. What movie name did you search for specifically?

This is the code I tested with and didn't have a problem.
        var api = new Tmdb(apikey, "fr");

        api.SearchMovie("Aliens", 1, null, (result) =>
            {
                var d = result.Data;
            });
Thanks

GwenGuts wrote Nov 8, 2012 at 12:18 PM

Hi,
<br><br>
Thanks for your response.
<br>
I will describe what i do, my purpose is to get a random movie.
<br><br>
So, i changed my way to do that:
<br><br>
1) I initialize my Api:
<br>
public void Initialize(string apiKey)<br>
    {<br>
        if (this._Api == null)<br>
        {<br>
            this._Api = new Tmdb(apiKey, "fr");<br>
            this._Api.GetConfiguration(null, result => _Configuration = result.Data);<br>
        }<br>
    }<br>
<br><br>
2) I initialize a list of genres:
<br>
this._Api.GetGenreList("fr", null,result =><br>
        {<br>
            if (result.Data != null)<br>
            {<br>
                if (result.Data.genres.Count > 0)<br>
                {<br>
                    this._myListGenre = result.Data.genres;<br>

                }<br>
            }<br>

        });<br>
<br><br>
3) Finally, I get a movie with a genre, using a random
<br><br>
this._Api.GetGenreMovies(this._myListGenre[new Random().Next(this._myListGenre.Count - 1)].id, 1, this._Api.Language, null, result =>
            {<br>
                if (result.Data != null)<br>
                {<br>
                    if (result.Data.total_results > 0)<br>
                    {<br>
                        GenreMovie  genreMovie = result.Data.results[new Random().Next(result.Data.results.Count - 1)];<br>
<br>
//My own object movie<br>
                        Movie movie = new Movie<br>
                        {<br>
                            Id = genreMovie.id, <br>
                            Title = genreMovie.title,<br>
                            PosterPath = new Uri(string.Format("{0}{1}{2}", this._Configuration.images.base_url, this._Configuration.images.poster_sizes[0], genreMovie.poster_path),
                        UriKind.Absolute),<br>
                        };<br> 
                        <br>
                        if (this.MovieFound != null)<br>
                        {<br>
                            this.MovieFound(new ModelResult<ObservableCollection<Movie>> { Result = new ObservableCollection<Movie> { movie } });<br>
                        }<br>
                    }<br>
                }<br>
            });<br>
<br><br>
It's in the 3rd part that i've an exception, always that DateTime FormatException.<br>
I believe that's because my Windows Phone emulator is setted to display french language .<br>
When i come back to an english display language, it works without problem.<br>
I work with the AppResources files to localize my app, i need that globalization to work.<br>
When I search with fr configuration in an english display language, it works, but if I search with an en configuration in a french display language, it crashes !<br>
<br>
All ideas are welcome :D...

GwenGuts wrote Nov 8, 2012 at 12:21 PM

Oups, sorry for the number of "<br>" inside my previous post ! I believed that Codeplex managed html in comments too !

wrote Nov 9, 2012 at 4:05 AM

watway wrote Nov 9, 2012 at 4:06 AM

Hi,

Could you please give the attached dll's a try and let me know.

I was able to repeat the problem by following your instructions with setting the emulator into French. Seemed the problem was actually parsing a double type, possibly due to difference in the decimal point character. There was a reported problem within RestSharp regarding this. Updating the RestSharp library to the latest version fixed the problem for me.

Let me know, and I'll upload a new version.

Thanks,
Craig

GwenGuts wrote Nov 9, 2012 at 6:39 AM

Hi,

It works great ! Big Thanks for the patch !

wrote Feb 14, 2013 at 6:53 PM

wrote Feb 20, 2013 at 12:31 PM