I'm trying to call a web api from .Net CF 2.0 code. The api works well and called directly from the browser, behaves as expected. The CF code compiles well, but when in debug, it fails on line
JSONResponse rp = JsonConvert.DeserializeObject<JSONResponse>(returnString);
JSONResponse class is:
public class JSONResponse{
[JsonProperty(PropertyName = "DbServerInstance")]
public string dbServerInstance { get; set; }
[JsonProperty(PropertyName = "DbServerUser")]
public string dbServerUser { get; set; }
[JsonProperty(PropertyName = "DbServerPassword")]
public string dbServerPassword { get; set; }
[JsonProperty(PropertyName = "DbServerDatabase")]
public string dbServerDatabase { get; set; }
[JsonProperty(PropertyName = "UserManualURL")]
public string userManualURL { get; set; }
[JsonProperty(PropertyName = "ApplicationName")]
public string applicationName { get; set; }
}
Error which I get is: {"Could not load type 'System.Runtime.CompilerServices.CompilerGeneratedAttribute' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC'."} System.Exception {System.TypeLoadException}
Should I upgrade the project to .Net CF 3.5? Or is it something else?
Any help and input appreciated.
edit: upgraded the project to CF 3.5, I'm getting the expected JSON string
<ArrayOfParameterSetUpdater><ParameterSetUpdater><DbServerDatabase>Py0/Pzw/MgM/Pz8/Rj8=</DbServerDatabase><DbServerInstance>PwlAaWU/cD8/fgo/Pyg/VQ==</DbServerInstance><DbServerPassword>PxUqNj9VO2Y/DV4vP0Z2Cg==</DbServerPassword><DbServerUser>FQEvDTI/QQwSP1I/Pz8/Pw==</DbServerUser><id>1</id></ParameterSetUpdater></ArrayOfParameterSetUpdater>
but now I get error {"Cannot deserialize JSON array into type 'app.JSONResponse'."} System.Exception {Newtonsoft.Json.JsonSerializationException}
From what I see, the class is correct, so I don't understand what is going wrong.
Any help and input appreciated.