【问题标题】:Exception web authentication result in windows phone silverlight 8.1Windows phone silverlight 8.1 中的异常 Web 身份验证结果
【发布时间】:2016-05-12 13:57:37
【问题描述】:

我想在我的windows phone 应用程序中使用Facebook 实现登录,当点击登录按钮时出现Facebook 的弹出窗口,在这里输入我的用户名和密码,一切都好,当我想获取令牌时,结果

WebAuthenticationResult myResult = await WebAuthenticationBroker.AuthenticateSilentlyAsync(startUri);

我得到了这个例外:

COMException 未被用户代码处理

“System.Runtime.InteropServices.COMException”类型的异常 发生在 mscorlib.ni.dll 中但未在用户代码中处理

附加信息:错误 HRESULT E_FAIL 已从 调用 COM 组件。

有解决这个问题的办法吗?

【问题讨论】:

  • 请让我看看你的完整代码。

标签: c# facebook silverlight windows-phone-8.1


【解决方案1】:

使用WebAuthenticationBroker.AuthenticateAndContinue(requestUri, callbackUri)代替WebAuthenticationBroker.AuthenticateSilentlyAsync(startUri),然后在App.xaml 中添加一个Application_ContractActivated 事件。您可以通过打开 App.xaml 并像这样添加 ContractActivated 来做到这一点

<shell:PhoneApplicationService ContractActivated="Application_ContractActivated" />

这应该在 App.xaml.cs 中添加 Application_ContractActivated 方法。在这种方法中,您可以得到如下结果:

public WebAuthenticationBrokerContinuationEventArgs WABContinuationArgs { get; set; }

        private void Application_ContractActivated(object sender, IActivatedEventArgs e)
                {
                    var _WABContinuationArgs = e as WebAuthenticationBrokerContinuationEventArgs;

                    if (_WABContinuationArgs != null)
                    {
                        WABContinuationArgs = _WABContinuationArgs;
                        var result = WABContinuationArgs.WebAuthenticationResult;
                    }
                }

请注意,此解决方案适用于 Windows Phone Silverlight 8.1,而不适用于 Windows Phone 8.1。对于 Windows Phone 8.1,原理相同,但您使用 OnActivated 方法而不是 Application_ContractActivated。

【讨论】:

    猜你喜欢
    • 2015-03-17
    • 2015-06-11
    • 2015-01-16
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2021-01-17
    • 2013-10-24
    相关资源
    最近更新 更多