2012-01-17 61 views
3

我從我的應用程序收到崩潰報告。我真的不明白問題是什麼。它從來沒有 與我墜毀...可能是什麼問題?從應用程序轂錯誤消息:應用程序崩潰。 KeyException?

0 coredll.dll xxx_RaiseException 19
1 mscoree3_7.dll 436488
2 mscoree3_7.dll 386545
3 mscoree3_7.dll 540936
4 TransitionStub 0
5 System.ThrowHelper.ThrowKeyNotFoundException 52
6 System.Collections.Generic.Dictionary 2.get_Item 136
7 System.IO.IsolatedStorage.IsolatedStorageSettings.get_Item 80
8 ScheduledTaskAgent1.ScheduledAgent.OnInvoke 660
9 Microsoft.Phone.Scheduler.ScheduledTaskAgent.Invoke 856
10 .AgentRequest.Invoke 764
11 Microsoft.Phone.BackgroundAgentDispatcher.InvocationThread 196
12 System.Threading.ThreadHelper.ThreadStartHelper 132
13 System.Threading.ThreadHelper.ThreadStart_Context 80
14 System.Threading.ExecutionContext.Run 324
15 System.Threading.ThreadHelper.ThreadStartHelper 168
16 mscoree3_7.dll 429164
17 mscoree3_7.dll 310125
18 mscoree3_7.dll 310319
19 mscoree3_7.dll 305995"

回答

8

貌似BackgroundAgent正試圖從一個不存在的IsolatedStorageSettings.ApplicationSettings加載的項目。檢入您的ScheduledTaskAgent1.ScheduledAgent.OnInvoke方法。

1 /取回

2 /如果該鍵不存在之前首先檢查使用「IsolatedStorageSettings.ApplicationSettings.Contains」方法的關鍵的存在,採取相應的行動

舉例來說,如果你'在做:

somevalue = IsolatedStorageSettings.ApplicationSettings["setting"]; 

然後「設置」是錯誤信息所指的關鍵。用您的代碼替換您的代碼:

if (IsolatedStorageSettings.ApplicationSettings.Contains("setting")) 
{ 
    somevalue = IsolatedStorageSettings.ApplicationSettings["setting"]; 
}else 
{ 
    // set somevalue to its default value 
}