I've been trying things in VS 2013. I decided to switch to see if things worked different in Xamarin Studio. I've decided to create a new solution in XS on my Mac. I've got the code below. Unfortunately, I am getting a message in XS saying "Compiler Crashed with Code: 1." Any ideas, thoughts, and ideas are appreciated.
Code:
using System;
using System.Net.Http;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace PCLWebServices
{
public class Data
{
public Data ()
{
}
async public System.Threading.Tasks.Task GetData(string location)
{
string contents;
WeatherReport res = new WeatherReport();
try
{
string Url = String.Format("http://api.openweathermap.org/data/2.5/forecast/daily?q={0}&mode=json&units=imperial&cnt=14",
location.Trim());
HttpClient hc = new HttpClient();
var str = await hc.GetStreamAsync(Url);
contents = await (new StreamReader(str)).ReadToEndAsync();
res = JsonConvert.DeserializeObject(contents);
foreach(var item in res.list)
{
HttpClient hcImage = new HttpClient();
var url = String.Format("http://openweathermap.org/img/w/{0}.png", item.weather[0].icon).Replace("dd", "d");
item.weather[0].Image = await hcImage.GetByteArrayAsync(url);
}
}
catch (System.Exception sysExc)
{
// Do soemthing to log this error.
throw;
}
return res;
}
}
}