locked
Application closes unexpectedly RRS feed

  • Question

  • Hi, I'm trying to implement a trial version to the application, but the application closes unexpectedly, though only when the debugger is NOT attached. The message box opens, if you click on Ok or Cancel it's all fine, but if you wait for 10 seconds, it suddenly closes. The code is executed in the OnNavigatedTo function and it looks like this: protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { TrialHelper.Instance.EndCheckTrial += EndCheckTrial; TrialHelper.Instance.CheckForTrial(this); base.OnNavigatedTo(e); } public bool CheckForTrial(UIElement element = null) { ... if (MessageBox.Show("foo", "foo title", MessageBoxButton.OKCancel) == MessageBoxResult.OK) element.Dispatcher.BeginInvoke(() => new MarketplaceDetailTask().Show()); ... } I've also tried to execute the code in the Application_Launching event, but the same thing occurs.
    Thursday, February 3, 2011 8:50 PM

Answers

  • You mentioned in your first post that you had tried it in the Application_Launching event.  Are you not drawing your first app screen until the message box is dismissed?  If so, the OS is terminating your app because it thinks it has failed to launch properly.  Apps must draw their first screen within ten seconds or the OS kills the app for bad behaviour.  To satisfy the certification requirements, you must draw your first app screen in less than five seconds.
    Friday, February 4, 2011 12:23 PM

All replies

  • I suspect that this is due to the phone not having network connectivity; IsTrial makes a synchronous call to the web.
    Try wrapping an exception handler around IsTrial to capture that exception and handle it.

    A related thread:
    http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/e27a7530-3ab9-4457-89a7-c4af7744458a#e27a7530-3ab9-4457-89a7-c4af7744458a

    Hope this helps,
    Mark
    Thursday, February 3, 2011 9:23 PM
  • I will try this, but I expect it not to work, because for testing I use this code: if(true || li.IsTrial()). I guess if it is compiled it will skip this code, because it is always true. And secondly: there is network connectivity, I'm certain about that. An even stranger part is this: When the code is executed it will show the messagebox described in my previous post. But for test purposes I have placed a messagebox beneeth the first one, like this: if(MessageBox.Show("foo .... ) == ....OK) element.Dispatcher.BeginInvoke(() => new MarketplaceDetailTask().Show()); MessageBox.Show("Test"); And when the messagebox foo is onscreen the application closes unexpectedly, just after it closes, it will show the Test messagebox. Maybe it has something to do with the background thread and UI thread?
    Friday, February 4, 2011 8:26 AM
  • Try Andy Pennell's Little Watson.  It will catch unhandled exceptions and then email them to you when the app is next launched.
    Friday, February 4, 2011 10:23 AM
  • Try Andy Pennell's Little Watson.  It will catch unhandled exceptions and then email them to you when the app is next launched.
    Allready done this, but it doesn't come up with any messages.
    Friday, February 4, 2011 11:54 AM
  • You mentioned in your first post that you had tried it in the Application_Launching event.  Are you not drawing your first app screen until the message box is dismissed?  If so, the OS is terminating your app because it thinks it has failed to launch properly.  Apps must draw their first screen within ten seconds or the OS kills the app for bad behaviour.  To satisfy the certification requirements, you must draw your first app screen in less than five seconds.
    Friday, February 4, 2011 12:23 PM
  • Apps must draw their first screen within ten seconds or the OS kills the app for bad behaviour.  To satisfy the certification requirements, you must draw your first app screen in less than five seconds.
    Thank you, this indeed was the problem. The solution is real simple, just execute the code in another Thread with (for example) this code: ThreadPool.QueueUserWorkItem(CheckTrial);
    Saturday, February 5, 2011 8:49 PM