2012-01-17 45 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 
}