2016-09-12 7 views
1

저는 Xamarin Android에서 개발 된 APP를 가지고 있으며 완벽하게 작동합니다. IOS Xamarin 버전을 만들고 있지만 비동기 오프라인 Azure를 활성화하는 데 문제가 있습니다. testo Device가 다음 오류를 생성하면 에뮬레이터가 작동합니다.Xamarin/IOS/Azure - 'id'회원이 없습니다.

" 'FM.Model.Categoria'유형에 'id'구성원이 없습니다. '

using Microsoft.WindowsAzure.MobileServices; 
using Microsoft.WindowsAzure.MobileServices.SQLiteStore; 
using Microsoft.WindowsAzure.MobileServices.Sync; 
using System; 
using System.IO; 
using System.Threading.Tasks; 

namespace FM.Dados 
{ 
    public class AtualizaDados 
    { 
     static AtualizaDados instance = new AtualizaDados(); 

     const string applicationURL = @"https://xxxx.azurewebsites.net"; 

     private MobileServiceClient client; 
     private IMobileServiceSyncTable<Model.Categoria> categoriaTable; 

     private AtualizaDados() 
     { 
      try 
      { 
       CurrentPlatform.Init(); 
       SQLitePCL.CurrentPlatform.Init(); 

       // Initialize the Mobile Service client with the Mobile App URL, Gateway URL and key 
       client = new MobileServiceClient(applicationURL); 

       // Create an MSTable instance to allow us to work with the TodoItem table 
       categoriaTable = client.GetSyncTable<Model.Categoria>(); 
      } 
      catch (Exception e) 
      { 
       Console.Error.WriteLine(@"Sync Failed: {0}", e.Message); 
      } 
     } 

     public static AtualizaDados DefaultService 
     { 
      get 
      { 
       return instance; 
      } 
     } 

     public async Task InitializeStoreAsync() 
     { 
      try 
      { 
       var store = new MobileServiceSQLiteStore(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "fm.db")); 
       store.DefineTable<Model.Categoria>(); 

       await client.SyncContext.InitializeAsync(store); 
      } 
      catch(Exception e) 
      { 
       Console.Error.WriteLine(@"Sync Failed: {0}", e.Message); 
      } 
     } 

     public async Task SyncAsync(bool pullData = false) 
     { 
      try 
      { 
       await client.SyncContext.PushAsync(); 

       if (pullData) 
       { 
        await categoriaTable.PullAsync("allCategoria", categoriaTable.CreateQuery()); 
       } 
      } 

      catch (MobileServiceInvalidOperationException e) 
      { 
       Console.Error.WriteLine(@"Sync Failed: {0}", e.Message); 
      } 
     } 
    } 
} 

속성 "Id"가 존재하지만 여전히 오류가 발생합니다.

using Newtonsoft.Json; 

namespace FM.Model 
{ 
    public class Categoria 
    { 
     public string Id { get; set; } 

     [JsonProperty(PropertyName = "Codigo")] 
     public int Codigo { get; set; } 

     [JsonProperty(PropertyName = "Nome")] 
     public string Nome { get; set; } 

     public bool Deleted { get; set; } 
    } 

} 

동일한 오류가있는 여러 사용자 포럼을 보았지만 해결 방법이 없습니다. 누구든지 어떤 아이디어가 될 수 있습니까? 에뮬레이터가 작동 한 이후로 일부 허가가 필요합니까?

답변

0

SyncTable을 받기 전에 상점을 정의하지 않은 것 같습니다.

  1. 가 초기화 가게
  2. 받기 동기화 표를
  3. 이 DefineTable
  4. 와 로컬 저장소 맵을 생성하는 클라이언트 만들기 : 여기에 필요한 자연적인 순서가있다.

이 시도 : 나는 오류의 장치에서 실행하려고하면 에뮬레이터에서

 try 
     { 
      CurrentPlatform.Init(); 
      SQLitePCL.CurrentPlatform.Init(); 

      // Initialize the Mobile Service client with the Mobile App URL, Gateway URL and key 
      client = new MobileServiceClient(applicationURL); 

      // Initialize the local offline store 
      await InitializeStoreAsync(); 

      // Create an MSTable instance to allow us to work with the TodoItem table 
      categoriaTable = client.GetSyncTable<Model.Categoria>(); 
     } 
+0

Adrian Hall, "store.DefineTable ();를 실행할 때 정보를 변경하여 동일한 오류가 발생했습니다." InitializeStoreAsync() –

+0

오프라인 캐시를 지워야 할 수도 있습니다. 기본 파일 만 제거하면됩니다. –

+0

또한 폴더의 사용 권한을 확인하십시오. 일반적으로 폴더 경로를 다룰 필요가 없습니다. 파일 이름을 지정하면 올바른 위치에 배치됩니다. –

0

이제 완전히 노력하고 있습니다. 허가를 받아야합니까? 오류 이유에 대해보고 할 항목이 없습니다. DB 파일의 경로를 알리려고했습니다.

관련 문제