0
我試着在腳本#腳本#調用REST服務
Uri uri = new Uri(string.Format(string.Concat("http://localhost:49175/GetProjects")));
WebRequest request = WebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Get;
request.ContentType = "application/json";
using (WebResponse response = request.GetResponse()) {
using (var reader = new System.IO.StreamReader(response.GetResponseStream())) {
string tmp = reader.ReadToEnd();
return JsonConvert.DeserializeObject<List<string>>(tmp);
}
}
使用此代碼,但我有這樣的錯誤:
Error 3 The assembly 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.dll' is not a valid script assembly.
是否在使用System.Net
,System.IO.StreamReader
和Newtonsoft.Json
方式腳本#?如果不可能,我該如何更改代碼?
您不能引用的.NET程序集的腳本#解決了這個問題。另外,S#只與C#2.0規範兼容。 – theoutlander