2014-01-16 69 views
1

我嘗試在代碼中打開一個SaveAppointmentTask這樣的:的例外是顯示

var saveAppointmentTask = new SaveAppointmentTask(); 

saveAppointmentTask.StartTime = e.Epg.StartDateTime; 
saveAppointmentTask.EndTime = e.Epg.EndDateTime; 
saveAppointmentTask.Subject = "some subject"; 
saveAppointmentTask.Location = "some location"; 
saveAppointmentTask.Details = "details"; 
saveAppointmentTask.IsAllDayEvent = false; 
saveAppointmentTask.Reminder = Reminder.FifteenMinutes; 
saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Free; 

saveAppointmentTask.Show(); 

但是當日歷打開例外外出時發生:

類型的未處理的異常「System.InvalidOperationException ' 發生在Microsoft.Phone.Interop.ni.dll

其他信息:狀態保存失敗。這很可能是由於 因狀態緩衝區容量不足所致。應用程序需要[3562259]字節 哪些可能超過NavServer限制

在我的應用程序中,我使用caliburn.micro。

是否有人知道真正發生了什麼以及我如何修復它?

+0

嘗試更換'SaveAppointmentTask'和使用'EmailComposeTask'代替,只是爲了看看是否出現同樣的異常。 –

+0

yeap。同樣的情況,同樣的例外。似乎是暫停應用程序的問題。它需要太長時間或什麼。 –

+1

就像我懷疑的一樣。我對Caliburn.Micro不熟悉,但我懷疑你有一個大視圖模型,在應用程序停用時被序列化。 –

回答

0

,您應該使用IEventAggregator,而不是由你自己創造一個SaveAppointmentTask

_eventAggregator.RequestTask<SaveAppointmentTask>(saveAppointmentTask => 
                  { 
                   saveAppointmentTask.StartTime = e.Epg.StartDateTime; 
                   saveAppointmentTask.EndTime = e.Epg.EndDateTime; 
                   saveAppointmentTask.Subject = "some subject"; 
                   saveAppointmentTask.Location = "some location"; 
                   saveAppointmentTask.Details = "details"; 
                   saveAppointmentTask.IsAllDayEvent = false; 
                   saveAppointmentTask.Reminder = Reminder.FifteenMinutes; 
                   saveAppointmentTask.AppointmentStatus = Microsoft.Phone.UserData.AppointmentStatus.Free; 

                  }); 
+0

不幸的是發生了同樣的異常... –