My app has already been published in the App Hub. But i received an error report sayin there is a crash caused by GuideAlreadyVisibleException.
I have used guide to show custom messages. What is this exception and when is it caused? Im not able to reproduce the crash in the device.
This is how i have used the guide messages
if (pCycMan.GetStartDate() == pCycMan.GetDefaultDate())
{
Guide.BeginShowMessageBox(resMan.GetString("msgboxWelcomeStringHeader"), resMan.GetString("msgboxWelcomeStringDescription1") + "\n" + resMan.GetString("msgboxWelcomeStringDescription2"),
new string[] { resMan.GetString("msgBoxWelcomeOk"), resMan.GetString("appBarIconFAQText") }, 1, MessageBoxIcon.None, new AsyncCallback(OnMessageBoxClosed), null);
}
else if (pCycMan.GetCycleStartDelay() > 0)
{
if (pCycMan.IsCyclePaused())
{
Guide.BeginShowMessageBox(resMan.GetString("msgboxCycleDelayPromptHeader"), resMan.GetString("msgboxCyclePausedPromptDescription") + "\n" + resMan.GetString("msgboxCycleDelayPromptDescription3"),
new string[] { resMan.GetString("msgBoxWelcomeOk"), resMan.GetString("appBarIconFAQText") }, 1, MessageBoxIcon.None, new AsyncCallback(OnMessageBoxClosed), null);
}
else
{
String delayMsg = resMan.GetString("msgboxCycleDelayPromptDescription1") + " " + pCycMan.GetCycleStartDelay().ToString() + " " + resMan.GetString("msgboxCycleDelayPromptDescription2")+ "\n" + resMan.GetString("msgboxCycleDelayPromptDescription3") ;
Guide.BeginShowMessageBox(resMan.GetString("msgboxCycleDelayPromptHeader"), delayMsg,
new string[] { resMan.GetString("msgBoxWelcomeOk"), resMan.GetString("appBarIconFAQText") }, 1, MessageBoxIcon.None, new AsyncCallback(OnMessageBoxClosed), null);
}
}
And
private void OnMessageBoxClosed(IAsyncResult msgboxresult)
{
int? buttonIndex = Guide.EndShowMessageBox(msgboxresult);
switch (buttonIndex)
{
case 0:
break;
case 1:
Deployment.Current.Dispatcher.BeginInvoke(() => NavigateToHelpPage());
break;
}
}
This issue can occur when a message box, input box, or any other prompt the Guide may show is opening, visible, or still closing when another prompt is trying to open.
Two possible examples would be if your application displays a message box after a user clicks a button. If the user clicks the button twice really fast before the prompt is shown, or the user clicks the button again before the first prompt closes all the way, the exception will be thrown.
I avoid this issue personally in some apps by adding a call to a helper method before I show any prompts. I have included a snippet that performs functionality similar to my helper method. I also add in a check to avoid an infinite loop by only letting it run for 3 seconds, after this I let the app crash if it needs to (but hopefully it doesn’t).