【发布时间】:2016-02-22 19:52:10
【问题描述】:
Printscreen 我的代码有错误和我的参考。 “ApplicationException”有一个错误,我只是不知道如何解决它。
using System;
using System.Net;
using System.Net.Http;
namespace Sharepoint_2013_REST_API
{
public class Program
{
public void Main(string[] args)
{
//Init
string baseURL = "hello";
string uriString = "world";
System.Net.Http.HttpClient _Client = new System.Net.Http.HttpClient();
_Client.BaseAddress = new Uri(baseURL);
HttpResponseMessage resp = _Client.GetAsync(uriString).Result;
string respString = resp.Content.ReadAsStringAsync().Result;
if (resp.StatusCode != HttpStatusCode.OK)
{
throw new ApplicationException("BAD");
}
}
}
}
错误通知:
错误 CS0246 找不到类型或命名空间名称“ApplicationException”(您是否缺少 using 指令或程序集引用?) 25
【问题讨论】:
-
你能构建 sln 吗?
-
不,'构建失败'
-
取决于您的目标框架,例如,它在 .NETCore 中不可用。从通用项目模板开始将是你的糟糕之处。 ApplicationException 是一个设计错误,只需使用 Exception 代替。并确保您确实打算使用通用模板,它看起来不是很通用。