Xamarin Form : Error on Login page when load
I have a login page where I have a check if user is logged in, then navigate to other page or stay on the login page. I don't want to put this code on App.cs
because login page will not open on 1st load of app. Now when I navigate to login page my app crash and throws the error:
GC_BRIDGE: Complete, was running for 0.09ms 11-16 12:31:55.111 D/Mono
(15701): GC_MINOR: (Nursery full) time 35.82ms, stw 36.83ms promoted
1009K major size: 531904K in use: 471305K los size: 2048K in use: 49K
Here is my code
public partial class Logins : ContentPage
{
public Logins()
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
if (!string.IsNullOrEmpty(Setings.AccessToken))
//
Navigation.PushAsync(new CartDetail());
else
Navigation.PushAsync(new Logins());
xamarin.forms
add a comment |
I have a login page where I have a check if user is logged in, then navigate to other page or stay on the login page. I don't want to put this code on App.cs
because login page will not open on 1st load of app. Now when I navigate to login page my app crash and throws the error:
GC_BRIDGE: Complete, was running for 0.09ms 11-16 12:31:55.111 D/Mono
(15701): GC_MINOR: (Nursery full) time 35.82ms, stw 36.83ms promoted
1009K major size: 531904K in use: 471305K los size: 2048K in use: 49K
Here is my code
public partial class Logins : ContentPage
{
public Logins()
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
if (!string.IsNullOrEmpty(Setings.AccessToken))
//
Navigation.PushAsync(new CartDetail());
else
Navigation.PushAsync(new Logins());
xamarin.forms
try executing app in other version of android than check what happening. Where exception throwing when you debugging.
– CGPA6.4
Nov 16 '18 at 7:47
what u mean other version of android? and i have added this code in exception it doesnt throw any exception its just crash
– waqas waqas
Nov 16 '18 at 7:59
add a comment |
I have a login page where I have a check if user is logged in, then navigate to other page or stay on the login page. I don't want to put this code on App.cs
because login page will not open on 1st load of app. Now when I navigate to login page my app crash and throws the error:
GC_BRIDGE: Complete, was running for 0.09ms 11-16 12:31:55.111 D/Mono
(15701): GC_MINOR: (Nursery full) time 35.82ms, stw 36.83ms promoted
1009K major size: 531904K in use: 471305K los size: 2048K in use: 49K
Here is my code
public partial class Logins : ContentPage
{
public Logins()
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
if (!string.IsNullOrEmpty(Setings.AccessToken))
//
Navigation.PushAsync(new CartDetail());
else
Navigation.PushAsync(new Logins());
xamarin.forms
I have a login page where I have a check if user is logged in, then navigate to other page or stay on the login page. I don't want to put this code on App.cs
because login page will not open on 1st load of app. Now when I navigate to login page my app crash and throws the error:
GC_BRIDGE: Complete, was running for 0.09ms 11-16 12:31:55.111 D/Mono
(15701): GC_MINOR: (Nursery full) time 35.82ms, stw 36.83ms promoted
1009K major size: 531904K in use: 471305K los size: 2048K in use: 49K
Here is my code
public partial class Logins : ContentPage
{
public Logins()
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
if (!string.IsNullOrEmpty(Setings.AccessToken))
//
Navigation.PushAsync(new CartDetail());
else
Navigation.PushAsync(new Logins());
xamarin.forms
xamarin.forms
edited Nov 16 '18 at 12:24
Joehl
2,65931742
2,65931742
asked Nov 16 '18 at 7:41
waqas waqaswaqas waqas
7118
7118
try executing app in other version of android than check what happening. Where exception throwing when you debugging.
– CGPA6.4
Nov 16 '18 at 7:47
what u mean other version of android? and i have added this code in exception it doesnt throw any exception its just crash
– waqas waqas
Nov 16 '18 at 7:59
add a comment |
try executing app in other version of android than check what happening. Where exception throwing when you debugging.
– CGPA6.4
Nov 16 '18 at 7:47
what u mean other version of android? and i have added this code in exception it doesnt throw any exception its just crash
– waqas waqas
Nov 16 '18 at 7:59
try executing app in other version of android than check what happening. Where exception throwing when you debugging.
– CGPA6.4
Nov 16 '18 at 7:47
try executing app in other version of android than check what happening. Where exception throwing when you debugging.
– CGPA6.4
Nov 16 '18 at 7:47
what u mean other version of android? and i have added this code in exception it doesnt throw any exception its just crash
– waqas waqas
Nov 16 '18 at 7:59
what u mean other version of android? and i have added this code in exception it doesnt throw any exception its just crash
– waqas waqas
Nov 16 '18 at 7:59
add a comment |
1 Answer
1
active
oldest
votes
You have a recursive navigation inside your constructor.
When the property Setings.AccessToken
is empty you navigate to a new Logins
page. Because you create a new Logins
page, you also check again for the AccessToken
. And it is still empty, so you create again a new Logins
page and again and again and again...
Quote from your question
[...] or stay on the login page.
To stay on the page, just don't navigate to it in the constructor. Leave the else
part empty will show the Logins
page.
Hint: It is not recommended to navigate inside a constructor, because of two reasons:
- The navigation method
PushAsync
is asynchronous. So you can wait on it until the navigation finishes (that is not possible in the constructor) - You should check for navigation outside the page itself (in fact: before you create the
Logins
page first). Or: You have to load the page, and check theAccessToken
afterwards. Why? You create a page to show it, and not to check if another one needs to be shown...
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333411%2fxamarin-form-error-on-login-page-when-load%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have a recursive navigation inside your constructor.
When the property Setings.AccessToken
is empty you navigate to a new Logins
page. Because you create a new Logins
page, you also check again for the AccessToken
. And it is still empty, so you create again a new Logins
page and again and again and again...
Quote from your question
[...] or stay on the login page.
To stay on the page, just don't navigate to it in the constructor. Leave the else
part empty will show the Logins
page.
Hint: It is not recommended to navigate inside a constructor, because of two reasons:
- The navigation method
PushAsync
is asynchronous. So you can wait on it until the navigation finishes (that is not possible in the constructor) - You should check for navigation outside the page itself (in fact: before you create the
Logins
page first). Or: You have to load the page, and check theAccessToken
afterwards. Why? You create a page to show it, and not to check if another one needs to be shown...
add a comment |
You have a recursive navigation inside your constructor.
When the property Setings.AccessToken
is empty you navigate to a new Logins
page. Because you create a new Logins
page, you also check again for the AccessToken
. And it is still empty, so you create again a new Logins
page and again and again and again...
Quote from your question
[...] or stay on the login page.
To stay on the page, just don't navigate to it in the constructor. Leave the else
part empty will show the Logins
page.
Hint: It is not recommended to navigate inside a constructor, because of two reasons:
- The navigation method
PushAsync
is asynchronous. So you can wait on it until the navigation finishes (that is not possible in the constructor) - You should check for navigation outside the page itself (in fact: before you create the
Logins
page first). Or: You have to load the page, and check theAccessToken
afterwards. Why? You create a page to show it, and not to check if another one needs to be shown...
add a comment |
You have a recursive navigation inside your constructor.
When the property Setings.AccessToken
is empty you navigate to a new Logins
page. Because you create a new Logins
page, you also check again for the AccessToken
. And it is still empty, so you create again a new Logins
page and again and again and again...
Quote from your question
[...] or stay on the login page.
To stay on the page, just don't navigate to it in the constructor. Leave the else
part empty will show the Logins
page.
Hint: It is not recommended to navigate inside a constructor, because of two reasons:
- The navigation method
PushAsync
is asynchronous. So you can wait on it until the navigation finishes (that is not possible in the constructor) - You should check for navigation outside the page itself (in fact: before you create the
Logins
page first). Or: You have to load the page, and check theAccessToken
afterwards. Why? You create a page to show it, and not to check if another one needs to be shown...
You have a recursive navigation inside your constructor.
When the property Setings.AccessToken
is empty you navigate to a new Logins
page. Because you create a new Logins
page, you also check again for the AccessToken
. And it is still empty, so you create again a new Logins
page and again and again and again...
Quote from your question
[...] or stay on the login page.
To stay on the page, just don't navigate to it in the constructor. Leave the else
part empty will show the Logins
page.
Hint: It is not recommended to navigate inside a constructor, because of two reasons:
- The navigation method
PushAsync
is asynchronous. So you can wait on it until the navigation finishes (that is not possible in the constructor) - You should check for navigation outside the page itself (in fact: before you create the
Logins
page first). Or: You have to load the page, and check theAccessToken
afterwards. Why? You create a page to show it, and not to check if another one needs to be shown...
answered Nov 16 '18 at 12:31
JoehlJoehl
2,65931742
2,65931742
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333411%2fxamarin-form-error-on-login-page-when-load%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
try executing app in other version of android than check what happening. Where exception throwing when you debugging.
– CGPA6.4
Nov 16 '18 at 7:47
what u mean other version of android? and i have added this code in exception it doesnt throw any exception its just crash
– waqas waqas
Nov 16 '18 at 7:59