【发布时间】:2013-06-25 04:08:48
【问题描述】:
我正在使用适用于 Android 的 Xamarin,并添加了 azure 移动服务组件。
我正在尝试创建类似 (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);
我使用adapter 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
如果需要,我很乐意提供其余代码。
已编辑
我可以获得异常级别的唯一方法是在调试时从监视窗口获取详细信息。
异常有 2 个属性:Request&Response
请求:
- 请求 {Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest} Microsoft.WindowsAzure.MobileServices.ServiceFilterRequest
接受“应用程序/json”字符串
内容 "{\"text\": \"tyu\", \"complete\": false}" 字符串
内容类型“应用程序/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
AbsolutePath "/.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 布尔值
IsDefaultPort true 布尔
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 bool
用户信息 "" 字符串
+ 静态成员
+ 非公开会员
静态成员
响应
- 响应 {Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse} Microsoft.WindowsAzure.MobileServices.ServiceFilterResponse
内容 "{\"code\":404,\"error\":\"Error: Not Found\"}" 字符串
内容类型“应用程序/json”字符串
- 标题计数 = 8 System.Collections.Generic.Dictionary
- 项目 {System.Collections.Generic.KeyValuePair[8]} System.Collections.Generic.KeyValuePair[]
- [0] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“缓存控制”字符串
值“无缓存”字符串
+ 非公开会员
- [1] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“内容长度”字符串
值“39”字符串
+ 非公开会员
- [2] {System.Collections.Generic.KeyValuePair} System.Collections.Generic.KeyValuePair
键“内容类型”字符串
值“应用程序/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 整数
StatusDescription“未找到”字符串
【问题讨论】:
-
异常对象的详细信息是什么?
-
@carlosfigueira 我用详细信息编辑了问题,我得到的回复 404 not found
-
这看起来很奇怪:
string mobileServiceUrl = "http://MyMoblieService.azure-mobile.net/.azure-mobile.net/- 你确定你有正确的 URL 吗?我真的怀疑它应该在域名后面有 ./azure-mobile.net/... -
@carlosfigueira 这是问题所在,非常感谢
标签: c# azure xamarin.android xamarin azure-mobile-services