我正在使用Visual Studio 2012和WP8 SDK編寫Windows Phone應用程序,Target Windows Phone OS Version
設置爲Windows Phone OS 7.1
。 模式是調試和測試我正在使用SDK出貨的「Emulator 7.8」(與「Emulator 7.1」和WP8仿真器相同的結果,甚至在我的WP7.8設備上)。WP7.1 System.NotSupportedException:「LaunchForTest不受支持」
我的代碼如下:
#if DEBUG
public void Test()
{
if (ScheduledActionService.Find(ReminderName) != null) {
try {
ScheduledActionService.LaunchForTest(ReminderName,
TimeSpan.FromSeconds(1));
} catch (NotSupportedException e) {
System.Diagnostics.Debug.WriteLine(e.Message);
System.Diagnostics.Debug.WriteLine(e.ToString());
}
} else {
MessageBox.Show("No scheduled notification has been installed");
}
}
#endif
通過一個按鈕,我得到下面的調試輸出調用此方法後:
A first chance exception of type 'System.NotSupportedException' occurred in
Microsoft.Phone.dll LaunchForTest is not supported
System.NotSupportedException: LaunchForTest is not supported
at Microsoft.Phone.Scheduler.ScheduledActionService.LaunchForTest(String name, TimeSpan delay)
at RingReminder.Control.RingAgent.Test()
我在這裏損失,因爲ScheduledActionService.LaunchForTest方法狀態: Windows Phone OS | Supported in: 8.0, 7.1
。
在SO或Google上搜索這個問題也沒有提出任何問題。
感謝您的幫助
Arg,就是這樣。我花了很長時間才找到那一個。謝謝。 – 2013-04-06 13:20:25
沒問題,這不是最明顯的原因:) – keyboardP 2013-04-06 13:29:19