2016-09-12 28 views
1

私は、Xamarin Androidで開発されたAPPを完備しています。 IOS Xamarinのバージョンを行っていますが、非同期のオフラインAzureをアクティブにするのに問題があります。 testoデバイスが次のエラーを生成すると、エミュレータが動作します。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」が存在し、それでもエラーが発生します。

私は同じエラーでいくつかのユーザーフォーラムを見たことがありますが、解決策は私の問題を解決しませんでした。 誰でも何ができますか? エミュレータが動作してから何らかの許可が必要ですか?

答えて

0

SyncTableを取得する前にストアを定義していないようです。ここで必要とされている自然な順序があります:

  1. はDefineTable
  2. とローカルストアマップを生成し、クライアント
  3. を作成ストア
  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ファイルのパスを知らせようとしましたが、何もしませんでした。

関連する問題