在我的应用程序上工作以允许备份到 Skydrive,我能够让“登录”按钮正常工作。经过进一步完善后,我开始使用 LiveAuthClient.InitializeAsync 但似乎无论我把它放在哪里(UI线程与否)或者我通过什么范围,我总是会收到错误消息:
"An unhandled exception of type 'System.Runtime.Serialization.InvalidDataContractException' occurred in System.Windows.ni.dll"
使用以下调用堆栈:
System.Windows.ni.dll!MS.Internal.JoltHelper.OnUnhandledException(object sender, System.UnhandledExceptionEventArgs args)
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.ni.dll!System.Net.Browser.ClientHttpWebRequest.InvokeGetResponseCallback.AnonymousMethod__1b(object state2)
mscorlib.ni.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)
mscorlib.ni.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.ni.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
mscorlib.ni.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()
mscorlib.ni.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
[Native to Managed Transition]
代码:
Microsoft.Live.LiveAuthClient auth = new Microsoft.Live.LiveAuthClient("ClientId");
auth.InitializeCompleted += auth_InitializeCompleted;
auth.InitializeAsync(new string[] { "wl.signin", "wl.offline_access", "wl.skydrive_update" });
使用 Windows Phone 7.1 和 VS 2012 express for Windows Phone 和 Live SDK 版本 5。任何帮助/见解将不胜感激!