远程过程调用失败
The remote procedure call failed
这是我的第一个 post,所以请对我放轻松:)
我正在做 a tutorial for Facebook SDK,我正在尝试从 Windows Phone XAML 应用程序登录 facebook 服务。
当我按照教程的步骤并点击登录按钮登录时,它工作正常,但是当我尝试自动执行此操作时,出现错误。
代码使用WebAuthenticationBroker,调用WebAuthenticationBroker.AuthenticateAndContinue(LoginUrl);
当我尝试将该代码放入 Loaded 事件时
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (this.fbHelper.AccessToken == null)
{
WebAuthenticationBroker.AuthenticateAndContinue(LoginUrl); //throws error
}
else
{
GetUserInfo();
}
}
我收到以下错误:
The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
我认为问题是页面还没有准备好执行逻辑,但我真的不知道我应该把代码放在哪里?
Broker好像可以在Window激活后调用。正如我所尝试的那样,它应该可以正常工作:
public MainPage()
{
this.InitializeComponent();
Window.Current.Activated += Current_Activated;
}
private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
{
Window.Current.Activated -= Current_Activated;
Debug.WriteLine("Activated");
WebAuthenticationBroker.AuthenticateAndContinue(new Uri("https://google.com"));
}
当然它需要一些改进,但应该可以。请记住,Actived 事件可能出于多种原因被调用,例如在显示对话框之后。
这是我的第一个 post,所以请对我放轻松:)
我正在做 a tutorial for Facebook SDK,我正在尝试从 Windows Phone XAML 应用程序登录 facebook 服务。 当我按照教程的步骤并点击登录按钮登录时,它工作正常,但是当我尝试自动执行此操作时,出现错误。
代码使用WebAuthenticationBroker,调用WebAuthenticationBroker.AuthenticateAndContinue(LoginUrl);
当我尝试将该代码放入 Loaded 事件时
private void Page_Loaded(object sender, RoutedEventArgs e)
{
if (this.fbHelper.AccessToken == null)
{
WebAuthenticationBroker.AuthenticateAndContinue(LoginUrl); //throws error
}
else
{
GetUserInfo();
}
}
我收到以下错误:
The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
我认为问题是页面还没有准备好执行逻辑,但我真的不知道我应该把代码放在哪里?
Broker好像可以在Window激活后调用。正如我所尝试的那样,它应该可以正常工作:
public MainPage()
{
this.InitializeComponent();
Window.Current.Activated += Current_Activated;
}
private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
{
Window.Current.Activated -= Current_Activated;
Debug.WriteLine("Activated");
WebAuthenticationBroker.AuthenticateAndContinue(new Uri("https://google.com"));
}
当然它需要一些改进,但应该可以。请记住,Actived 事件可能出于多种原因被调用,例如在显示对话框之后。