我做了一个程序,使用Restsharp与一个asp.net web api web服务。在模拟器中一切都很好,但相同的代码在实际的iPhone上不起作用。我正在使用restsharp的monotouch版本 这里 .在模拟器中调试时,我使用了库的模拟器版本,在iphone上调试时,我使用了iPhone的模拟器版本。在iPhone上 response.Data 为null。(BTW有没有一种简单的方法可以在iphone上调试时自动使用iphone版本的库,在模拟器上调试时自动使用模拟器版本的库?)

var hh = client.ExecuteAsync<List<Accommodation>>(request, (response) => {
    //on the simulator this works, on the device response.Data is null
    if (response.StatusCode == HttpStatusCode.OK && response.Data != null)
        searchCompleteAction(response.Data);
    else
        searchCompleteAction(null);
        UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
});
有帮助吗?

解决方案

用这个 RestSharp 图书馆 [医]RestSharp Xamarin Components

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top