我有下面的代码,试图从Web API服务获取Appication对象。我得到的follwoing异常:ReadAsAsync - 抛出异常类型是一个接口或抽象类,不能立即
的InnerException = {“无法创建类型BusinessEntities.WEB.IApplicationField的一个实例类型是一个接口或抽象类,不能instantated路径“_applicationFormsList [0] ._ listApplicationPage [。 0] ._ listField [0] ._ applicationFieldID',line 1,position 194.“}。
我不明白为什么将FieldList更改为接口导致反序列化对象时出现问题。任何指针都非常感谢。
Task<HttpResponseMessage> task = HttpClientDI.GetAsync(someUri);
HttpResponseMessage response = task.Result;
HttpClientHelper.CheckResponseStatusCode(response);
try
{
Application application = response.Content.ReadAsAsync<ApplicationPage>().Result;
return application;
}
catch (Exception ex)
{
throw new ServiceMustReturnApplicationException(response);
}
[Serializable]
public class ApplicationPage
{
#region Properties
public int PageOrder { get; set; }
public string Title { get; set; }
public string HtmlPage { get; set; }
public int FormTypeLookupID { get; set; }
List<IApplicationField> _listField = new List<IApplicationField>();
public List<IApplicationField> FieldList
{
get { return _listField; }
set { _listField = value; }
}
}