Hi community. I'm using Xamarin Studio for first time and I then got this error when I create a simple app using Rest Services and Json data.
In this method appear the problem:
private async void LoadRates()
{
waitActivityIndicator.IsRunning = true;
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://openexchangerates.org");
string url = string.Format ("/api/latest.json?app_id=1b35af1ea346435dbddabbef5a7d8747");
var response = await client.GetAsync(url);
var result = response.Content.ReadAsStringAsync().Result;
waitActivityIndicator.IsRunning = false;
convertButton.IsEnabled = true;
if (string.IsNullOrEmpty (result))
{
await DisplayAlert("Error", "Bad request, you must try it later", "Accept");
convertButton.IsEnabled = false;
return;
}
this.exchangeRates = JsonConvert.DeserializeObject<ExchangeRates> (result);
}
This the error:
Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException
at --- End of managed exception stack trace ---
at java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
at Caused by: java.lang.reflect.InvocationTargetException
at at java.lang.reflect.Method.invoke(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:372)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at ... 1 more
at Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0 (object) [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006
at Android.App.SyncContext/c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Java.Lang.IRunnable.cs:71
at at (wrapper dynamic-method) object.b8060bd2-681d-468d-85ca-3c121dccebd2 (intptr,intptr)
at at mono.java.lang.RunnableImplementor.n_run(Native Method)
at at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
at at android.os.Handler.handleCallback(Handler.java:739)
at at android.os.Handler.dispatchMessage(Handler.java:95)
at at android.os.Looper.loop(Looper.java:135)
at at android.app.ActivityThread.main(ActivityThread.java:5254)
at ... 4 more
I don't know how to solve that, I need help!
Thanks a lot, regards from Colombia