저는 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; }
}
}
동일한 오류가있는 여러 사용자 포럼을 보았지만 해결 방법이 없습니다. 누구든지 어떤 아이디어가 될 수 있습니까? 에뮬레이터가 작동 한 이후로 일부 허가가 필요합니까?
Adrian Hall, "store.DefineTable();를 실행할 때 정보를 변경하여 동일한 오류가 발생했습니다." InitializeStoreAsync() –
오프라인 캐시를 지워야 할 수도 있습니다. 기본 파일 만 제거하면됩니다. –
또한 폴더의 사용 권한을 확인하십시오. 일반적으로 폴더 경로를 다룰 필요가 없습니다. 파일 이름을 지정하면 올바른 위치에 배치됩니다. –