2012-11-18 5 views
5

저는 Windows 8 Store Application을 보유하고 있으며 Azure 인증을 추가하고 싶습니다. MSDN 페이지의 예제를 따라했습니다. 그러나, 다음 줄은 나에게 문제를주고있다 :Azure 모바일 서비스 인증 - App.MobileService가 존재하지 않습니다.

MobileServiceUser loginResult = await App.MobileService.LoginAsync(result.Session.AuthenticationToken); 

오류는 다음과 같습니다 앱은 MobileService에 대한 정의가 포함되어 있지 않습니다. 언제 MobileService의 인스턴스가 App 클래스에 추가됩니까?

Microsoft.Live 및 Azure 모바일 서비스 라이브러리에 대한 참조가 추가되었습니다. 다음은 전체 Authenticate 함수입니다.

private async System.Threading.Tasks.Task Authenticate() 
     { 
     LiveAuthClient liveIdClient = new LiveAuthClient("<< INSERT REDIRECT DOMAIN HERE >>"); 


     while (session == null) 
     { 
      // Force a logout to make it easier to test with multiple Microsoft Accounts 
      if (liveIdClient.CanLogout) 
       liveIdClient.Logout(); 


      LiveLoginResult result = await liveIdClient.LoginAsync(new[] { "wl.basic" }); 
      if (result.Status == LiveConnectSessionStatus.Connected) 
      { 
       session = result.Session; 
       LiveConnectClient client = new LiveConnectClient(result.Session); 
       LiveOperationResult meResult = await client.GetAsync("me"); 
       MobileServiceUser loginResult = await App.MobileService.LoginAsync(result.Session.AuthenticationToken); 

       string title = string.Format("Welcome {0}!", meResult.Result["first_name"]); 
       var message = string.Format("You are now logged in - {0}", loginResult.UserId); 
       var dialog = new MessageDialog(message, title); 
       dialog.Commands.Add(new UICommand("OK")); 
       await dialog.ShowAsync(); 
      } 
      else 
      { 
       session = null; 
       var dialog = new MessageDialog("You must log in.", "Login Required"); 
       dialog.Commands.Add(new UICommand("OK")); 
       await dialog.ShowAsync(); 
      } 
     } 
    } 
+1

다른 포럼에서 Chris라는 누군가가 답변을주었습니다. 관리 대시 보드로 이동하여 모바일 앱을 선택하고 시작하기에서 "기존 Windows Store 앱 연결"링크를 클릭하십시오. 그런 다음 주어진 코드를 App 클래스에 복사하십시오. 내가 누락 된 것은 무엇인가. – user1490586

답변

9

직접 클래스를 추가해야합니다.

Azure 모바일 서비스에서 "시작하기 페이지"를 선택하고 "Windows Store"를 선택한 다음 "기존 Windows 스토어 APP 연결"을 선택하십시오 (외치다는 의미는 아닙니다).). 복사 한 후, 및 당신의 App.xaml.cs를 파일에 다음 코드를 붙여 넣습니다; "사용 Microsoft.WindowsAzure.MobileServices"

추가 :

은 다음을 수행 당신을 말할 것이다

public static MobileServiceClient MobileService = new MobileServiceClient(
    "https://[your website].azure-mobile.net/", 
    "[your key]" 
); 
+3

+1 '소리 치려하지 않았다'. – akshay2000