Hi,
I have a new Xamarin.Forms application, that right now contains two pages. An login screen and a dashboard. When I handle the login event on the login page i get an Exception with the PushModalAsync
method.
What I have:
App.cs
public static Page GetMainPage()
{
var mainPage = new Login();
return new NavigationPage(mainPage);
}
Login.xaml.cs
async void LoginClicked(object sender, EventArgs e)
{
Button login = (Button)sender;
//Handling the login logic
if(loginSuccess){
try
{
await this.Navigation.PushModalAsync(new Dashboard(username.Text, password.Text, true));
}
catch (Exception ex)
{
testlabel.Text = ex.Message + ":" + ex.StackTrace;
}
}
}
When I use Navigation.PushAsync(new Dashboard(username.Text ,password.Text, true));
it works fine, but for obvious reasons I don't want that the user can go back to the login screen. As far as I understand thats what PushModalAsync
is for. So that I have an Navigation stack for the other parts of the application.
Exception message:
"Resource ID #0xff212121"
Exception Stacktrace:
" at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 \n at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00084] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:896 \n at Android.Views.View.SetBackgroundResource (Int32 resid) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.18-series/3b7ef0a7/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Views.View.cs:14992 \n at Xamarin.Forms.Platform.Android.Platform.PresentModal (Xamarin.Forms.Page modal) [0x00000] in <filename unknown>:0 \n at Xamarin.Forms.Platform.Android.Platform+<PushModalAsync>d__8.MoveNext () [0x00000] in <filename unknown>:0 \n--- End of stack trace from previous location where exception was thrown ---\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 \n at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 \n at mCRM.Login+<LoginClicked>d__0.MoveNext () [0x00041] in c:\\Users\\Schindler\\Documents\\Visual Studio 2012\\Projects\\mCRM\\mCRM\\mCRM\\Login.xaml.cs:30 \n --- End of managed exception stack trace ---\nandroid.content.res.Resources$NotFoundException: Resource ID #0xff212121\n\tat android.content.res.Resources.getValue(Resources.java:1193)\n\tat android.content.res.Resources.getDrawable(Resources.java:744)\n\tat android.content.Context.getDrawable(Context.java:401)\n\tat android.view.View.setBackgroundResource(View.java:15769)\n\tat xamarin.forms.platform.android.ButtonRenderer_ButtonClickListener.n_onClick(Native Method)\n\tat xamarin.forms.platform.android.ButtonRenderer_ButtonClickListener.onClick(ButtonRenderer_ButtonClickListener.java:29)\n\tat android.view.View.performClick(View.java:4598)\n\tat android.view.View$PerformClick.run(View.java:19268)\n\tat android.os.Handler.handleCallback(Handler.java:738)\n\tat android.os.Handler.dispatchMessage(Handler.java:95)\n\tat android.os.Looper.loop(Looper.java:135)\n\tat android.app.ActivityThread.main(ActivityThread.java:5070)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat java.lang.reflect.Method.invoke(Method.java:372)\n\tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)\n"
Just to mention that this is my first Xamarin.Forms app.