这是错误消息。
类型' System.InvalidOperationException'的例外情况发生在System.Windows.ni.dll中但未在用户代码中处理 附加信息:显示MessageBox时出错。最常见的原因是在应用程序启动或激活时尝试调用Show。在调用Show。
之前等待页面导航事件当应用程序启动时,它会在开始时发生,并在尝试显示消息框时在第一个if语句中停止此功能。
代码来源= How to implement a trial experience in a Windows Phone app
private void CheckLicense()
{
// this displays a dialog so that we can simulate trial mode being on or off.
#if DEBUG
string message = "Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.";
if (MessageBox.Show(message, "Debug Trial",
MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
_isTrial = true;
}
else
{
_isTrial = false;
}
#else
_isTrial = _licenseInfo.IsTrial();
#endif
}
答案 0 :(得分:3)
由于错误表明在第一页导航之前无法显示消息框。
MSDN有一个特定于trial experience on Windows Phone 8的示例。它是由Windows Phone团队编写的,初始化代码中没有任何消息框。
答案 1 :(得分:0)
我有同样的问题。这是解决方案。 您需要将消息框括起来 [Deployment.Current.Dispatcher.BeginInvoke] 例如:
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show(message, title, MessageBoxButton.OK);
});