2012-02-29 38 views
0

我的应用程序已经发布在App Hub中。但是我收到了一个错误报告,说有一个由GuideAlreadyVisibleException引起的崩溃。 我已经使用指南来显示自定义消息。这个例外是什么,它是什么时候引起的?我无法重现设备中的崩溃。Stack Trace,GuideAlreadyVisibleException

这是如何我已经使用所述引导消息

  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); 
       } 
      } 

而且

 private void OnMessageBoxClosed(IAsyncResult msgboxresult) 
    { 
     int? buttonIndex = Guide.EndShowMessageBox(msgboxresult); 
     switch (buttonIndex) 
     { 
      case 0: 
       break; 

      case 1: 
       Deployment.Current.Dispatcher.BeginInvoke(() => NavigateToHelpPage()); 
       break; 
     } 
    } 
+0

您是否有异常的堆栈跟踪? – 2012-03-01 00:18:16

+0

@MattLacey StackTrace-框架图像功能, coredll.dll中xxx_RaiseException, mscoree3_7.dll WatsonUnhandledManagedException, mscoree3_7.dll Dbg_NotifyManagedException, mscoree3_7.dll FirstPassException, TransitionStub, Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox, Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox, LoveCycles_Free.MainPage.HistoryDe​​lClick, System.Windows.Controls.Primitives.ButtonBase.OnClick, System.Windows.Controls.Button.OnClick, System.Windows.Controls。 Primitives.ButtonBase.OnMouseLeftButtonUp, – alfah 2012-03-01 05:44:57

+0

System.Windows.Controls.Control.OnMous eLeftButtonUp, S.Internal.JoltHelper.FireEvent, mscoree3_7.dll IL_CallManaged, mscoree3_7.dll IL_CallDelegateInternal, mscoree3_7.dll makeComPlusCall, mscoree3_7.dll makeComPlusCallReturnInt, CCoreServices :: CLR_FireEvent, CControlBase :: ScriptCallback, 什么所有这一切意味着:O – alfah 2012-03-01 05:45:27

回答

1

此问题当一个消息框,输入框,或任何其它提示的指南可以示出被打开可以发生,可见或在另一个提示试图打开时仍然关闭。

如果您的应用程序在用户单击按钮后显示消息框,将会出现两个可能的示例。如果用户在显示提示之前快速点击两次按钮,或者用户在第一次提示关闭前再次单击该按钮,则将引发异常。

我在某些应用程序中通过在显示任何提示之前向辅助方法添加调用来避免此问题。我已经包含一个执行类似于我的帮助方法的功能的代码片段。我还添加了一个检查来避免无限循环,只让它运行3秒,之后我让应用程序崩溃(如果需要的话)(但希望它不会)。

public static void GuideSafetyWait(int maxDuration) 
{ 
    DateTime timeStarted = DateTime.Now; 
    while (Guide.IsVisible) 
    { 
     if ((DateTime.Now - timeStarted).TotalMilliseconds >= maxDuration) 
      break; // Prevent infinite loop. 

     Thread.Sleep(10); // This could be any number of milliseconds, but 
          // if its too high, it may deliver a poor user experience. 
    } 
}