Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在OnNavigatedTo事件中使用WebAuthenticationBroker.AuthenticateAndContinue时出现异常_C#_Windows Phone 8.1 - Fatal编程技术网

C# 在OnNavigatedTo事件中使用WebAuthenticationBroker.AuthenticateAndContinue时出现异常

C# 在OnNavigatedTo事件中使用WebAuthenticationBroker.AuthenticateAndContinue时出现异常,c#,windows-phone-8.1,C#,Windows Phone 8.1,在my主页的OnNavigatedTo事件中使用WebAuthenticationBroker.AuthenticateAndContinue时,我会遇到以下异常: 远程过程调用失败。(来自HRESULT的异常:0x800706BE) 但是,如果我创建了一个带有click事件的按钮,它执行完全相同的函数调用,我不会得到异常。我认为原因是当触发OnNavigatedTo事件时,页面没有完全加载 那么,我应该如何创建一个页面,在导航到该页面时自动启动授权过程,而无需中间控件(如按钮)?如果我尝试在页

在my
主页的
OnNavigatedTo
事件中使用
WebAuthenticationBroker.AuthenticateAndContinue
时,我会遇到以下异常:

远程过程调用失败。(来自HRESULT的异常:0x800706BE)

但是,如果我创建了一个带有click事件的按钮,它执行完全相同的函数调用,我不会得到异常。我认为原因是当触发
OnNavigatedTo
事件时,页面没有完全加载


那么,我应该如何创建一个页面,在导航到该页面时自动启动授权过程,而无需中间控件(如按钮)?

如果我尝试在页面加载事件上执行该令牌请求函数,我会收到与您相同的错误:

String FacebookURL = "https://www.facebook.com/dialog/oauth?client_id=" + Uri.EscapeDataString(FacebookClientID.Text) + "&redirect_uri=" + Uri.EscapeDataString(FacebookCallbackUrl.Text) + "&scope=read_stream&display=popup&response_type=token";

System.Uri StartUri = new Uri(FacebookURL);
System.Uri EndUri = new Uri(FacebookCallbackUrl.Text);

WebAuthenticationBroker.AuthenticateAndContinue(StartUri, EndUri, null, WebAuthenticationOptions.None);
我用来做这项工作的变通方法包括一个调度员

    DispatcherTimer timer = new DispatcherTimer();
    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        timer.Interval = new TimeSpan(0, 0, 0);
        timer.Tick += timer_Tick;
        timer.Start();
    }
    void timer_Tick(object sender, object e)
    {
        timer.Stop();
        String FacebookURL = "https://www.facebook.com/dialog/oauth?client_id=" + Uri.EscapeDataString(FacebookClientID.Text) + "&redirect_uri=" + Uri.EscapeDataString(FacebookCallbackUrl.Text) + "&scope=read_stream&display=popup&response_type=token";
        System.Uri StartUri = new Uri(FacebookURL);
        System.Uri EndUri = new Uri(FacebookCallbackUrl.Text);
        WebAuthenticationBroker.AuthenticateAndContinue(StartUri, EndUri, null, WebAuthenticationOptions.None);            
    }

您是否尝试过加载事件<代码>this.Loaded+=(发送方,e)=>{//here}奇怪,我还是有同样的例外。你的目标是Silverlight还是RT?我刚刚尝试了RT,似乎在加载的事件中工作。请使用WebAuthenticationBroker发布整个代码。这不是答案。如果您有新问题,请使用“提问”按钮。