0
我試圖推出測試WP7這樣的代碼:RestSharp不工作的WP7測試
var client = new RestClient("http://google.com");
var request = new RestRequest(Method.GET);
client.ExecuteAsync(request, response => Debug.WriteLine(response.StatusCode);
這個代碼寫HttpStatusCode = 0,提高錯誤:
The type initializer for 'System.Net.WebRequest' threw an exception. System.TypeInitializationException
如何修復?
更新#1
例如,此代碼在Windows類庫罰款,但在Silverlight和WP7項目不起作用:
var client = new RestClient("http://carma.org/api/1.1/searchPlants");
var request = new RestRequest();
request.AddParameter("location", 4338);
request.AddParameter("limit", 10);
request.AddParameter("color", "red");
request.AddParameter("format", "xml");
var plants = client.ExecuteAsync(
request, response => Assert.AreEqual(HttpStatusCode.OK, response.StatusCode));
我也試過MS單元測試,並開始與ReSharper(AgUnit和無),Statlight,NCrunch,與不同的庫,但仍然發生此錯誤。其他測試中沒有問題,只有使用RestSharp。 – dublicator
在Silverlight項目中也有同樣的錯誤。 – dublicator