您的位置:首页 > 移动开发

System.Exception when running SearchAsync of Contacts in application_launching event handler 未处理Exception

2012-06-06 22:14 555 查看
Why do i get this exception:

System.Exception was unhandled

Message=Exception
StackTrace:
at
Microsoft.Phone.UserData.QueryDataEnumerable`1.EnsureInteropInit()
at
Microsoft.Phone.UserData.QueryDataEnumerable`1.GetNextBatch(Int32
nextIndex)
at
Microsoft.Phone.UserData.QueryDataEnumerator`1.MoveNext()
at
Microsoft.Phone.UserData.Contacts.GetContacts(Object state)
at
System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Threading.ThreadPool.WorkItem.doWork(Object o)
at
System.Threading.Timer.ring()

when i run these lines of code in the
"application_launching" event handler on App.xaml.cs
Contacts cons = new Contacts();
cons.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(CompletedSearch);

cons.SearchAsync(null, FilterKind.PhoneNumber, null);

Note: if i comment out
the line

cons.SearchAsync(null, FilterKind.PhoneNumber, null);

I dont get an exception
anymore. But I need that to run in order for my app to
work!!

Thanks,
David

Re: System.Exception
when running SearchAsync of Contacts in application_launching event handler

Reply Quote
Hi,
In WMMainfeast.xml,Did u set the capapability of the application to access
contacts:
<Capability Name="ID_CAP_CONTACTS"/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐