【发布时间】:2017-02-27 20:01:04
【问题描述】:
我是移动开发的新手,我在使用 Xamarin Forms 应用程序时遇到了问题。我有一个 Azure 订阅,其中包含一个连接到我的数据库的移动应用程序设置。我已经从 Azure 中的 Mobile App Quickstart 链接下载了两个快速启动项目,并重新配置它们以在我的数据库中查找名为“users”的表并从中返回数据。
当我从使用 MacBook Pro 作为模拟器的 Visual Studio 运行应用程序时,列表返回为空白。我设置了几个断点,我可以看到它表明找不到资源。
当它查找表以返回一个集合时,它会在方法中遇到问题,如下所示:
public async Task<ObservableCollection<users>> GetUserItemsAsync(bool syncItems = false)
{
try
{
#if OFFLINE_SYNC_ENABLED
if (syncItems)
{
await this.SyncAsync();
}
#endif
IEnumerable<users> items = await userTable.ToEnumerableAsync();
return new ObservableCollection<users>(items);
}
//Hits this catch
catch (MobileServiceInvalidOperationException msioe)
{
Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message, msioe.StackTrace, msioe.Request, msioe.Response);
}
catch (Exception e)
{
Debug.WriteLine(@"Sync error: {0}", e.Message);
}
return null;
}
返回的错误如下:
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
我在 catch 语句中添加了响应和请求,以尝试查看到底是什么问题。该请求返回以下内容:
{Method: GET, RequestUri: 'https://myurl.azurewebsites.net/tables/users', Version: 1.1, Content: <null>, Headers:
{
X-ZUMO-FEATURES: TT
X-ZUMO-INSTALLATION-ID: r8fv3f71-12e9-416f-a976-8are363cf3b7
Accept: application/json
User-Agent: ZUMO/3.1 (lang=Managed; os=iOS; os_version=10.2; arch=MacOSX; version=3.1.50105.0)
X-ZUMO-VERSION: ZUMO/3.1 (lang=Managed; os=iOS; os_version=10.2; arch=MacOSX; version=3.1.50105.0)
ZUMO-API-VERSION: 2.0.0
}}
我可以看到它认为要么桌子不在那里,要么它是空的。我创建了表格并用虚拟数据填充了它,所以我知道它就在那里。
也许我的过程是错误的,我从连接到我的 Azure 订阅的 Visual Studio 中创建了表。表需要以某种方式设置吗?我应该在 Azure 中使用 Easy Tables 吗?
我需要一些指导来理解为什么我的应用看不到我的数据库表。
【问题讨论】: