我正在使用 Xamarin for Android 并添加了 azure 移动服务组件。
我正在尝试创建待办事项列表应用程序,例如(https://github.com/xamarin/azure-mobile-services https://github.com/xamarin/azure-mobile-services)
我这样连接到移动服务:
public static string mobileServiceUrl = "http://MyMoblieService.azure-mobile.net/.azure-mobile.net/";
public static string mobileServiceAppKey = "MyAppKey";
private static readonly MobileServiceClient MobileService =
new MobileServiceClient(mobileServiceUrl, mobileServiceAppKey);
this.adapter = new TodoAdapter(MobileService.GetTable<Item>(), this);
我使用 Adapte Insert 函数将数据插入表中
public void Insert(Item item)
{
IsUpdating = true;
this.items.Add(item);
NotifyDataSetChanged();
this.table.InsertAsync(item).ContinueWith(t =>
{
if (t.IsFaulted)
{
this.items.Remove(item);
NotifyDataSetChanged();
}
IsUpdating = false;
}, scheduler);
}
每次我得到t.IsFaulted = true
,在调试时,当我挖掘 t.Exception 时,我发现Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException
如果需要的话,我很乐意提供其余的代码。
Edited我获得异常级别的唯一方法是在调试时从监视窗口获取详细信息。
异常有2个属性:Request&Response
请求:
- 请求 {Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest} Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest
接受“application/json”字符串
内容 "{\"text\": \"tyu\", \"complete\": false}" 字符串
ContentType“application/json”字符串
- 标头计数=2 System.Collections.Generic.Dictionary
- 项目 {System.Collections.Generic.KeyValuePair[2]} System.Collections.Generic.KeyValuePair[]
- [0] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“X-ZUMO-INSTALLATION-ID”字符串
值“17b22eec-edd2-4a15-a37f-d4c5d87e4e8e”字符串
+ 非公开会员
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“X-ZUMO-APPLICATION”字符串
值“FmlVNVhdQhNEAIZZVptKhxlQNuJrlq37”字符串
+ 非公开会员
+ 原始视图
方法“POST”字符串
- Uri {System.Uri} System.Uri
绝对路径“/.azure-mobile.net/tables/Item”字符串
绝对Uri
权限“ichange.azure-mobile.net”字符串
DnsSafeHost“ichange.azure-mobile.net”字符串
片段“”字符串
主机“ichange.azure-mobile.net”字符串
HostNameType System.UriHostNameType.Dns System.UriHostNameType
IsAbsoluteUri true bool
IsDefaultPort true bool
IsFile false 布尔值
IsLoopback false bool
IsUnc false 布尔值
LocalPath“/.azure-mobile.net/tables/Item”字符串
原始字符串
PathAndQuery“/.azure-mobile.net/tables/Item”字符串
端口 80 内部
请求参数
方案“http”字符串
+ 段 {string[4]} string[]
UserEscaped false 布尔值
用户信息“”字符串
+ 静态成员
+ 非公开会员
静态成员
响应
- 响应 {Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse} Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse
内容 "{\"code\":404,\"error\":\"Error: Not Found\"}" 字符串
ContentType“application/json”字符串
- 标头计数=8 System.Collections.Generic.Dictionary
- 项目 {System.Collections.Generic.KeyValuePair[8]} System.Collections.Generic.KeyValuePair[]
- [0] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“Cache-Control”字符串
值“无缓存”字符串
+ 非公开会员
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“内容长度”字符串
值“39”字符串
+ 非公开会员
- [2] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“内容类型”字符串
值“application/json”字符串
+ 非公开会员
- [3] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“服务器”字符串
值“Microsoft-IIS/8.0”字符串
+ 非公开会员
- [4] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“Set-Cookie”字符串
值“ARRAffinity=3041b7170f63e41156a1ff0b65518583e91f68d4f90a680a7750bd8d12f209e0;Path=/;Domain=ichange.a…”字符串
+ 非公开会员
- [5] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“x-zumo-version”字符串
值“Zumo.Main.0.1.6.3017.Runtime”字符串
+ 非公开会员
- [6] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“X-Powered-By”字符串
值“ASP.NET”字符串
+ 非公开会员
- [7] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“日期”字符串
值“2013 年 6 月 27 日星期四 18:23:56 GMT”字符串
+ 非公开会员
+ 原始视图
ResponseStatus Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus.ProtocolError Microsoft.WindowsAzure.MobileServices.ServiceFilterResponseStatus
状态代码 404 整数
状态描述“未找到”字符串