I have an abstract class called 'Template' defined as:
[DataContract]
public abstract class Template
{
[DataMember]
public virtual int? Id { get; set; }
[DataMember]
public virtual string Title { get; set; }
[DataMember]
public virtual byte[] TemplateDoc { get; set; }
[DataMember]
public virtual bool IsSystemTemplate { get; set; }
}
Two derived classes: UserTemplate and SystemTemplate implements above abstract class, which are defined as:
public class UserTemplate : Template
{
[DataMember]
public virtual Int32? OfficeId { get; set; }
[DataMember]
public virtual Int32? UserId { get; set; }
protected UserTemplate() { }
public UserTemplate(string title, byte[] templateDoc, string templateDocName, TemplateType templateType, int officeId, int? userId)
{
this.Title = title;
this.TemplateDoc = templateDoc;
this.IsSystemTemplate = false;
this.OfficeId = officeId;
this.UserId = userId;
}
}
public class SystemTemplate : Template
{
[DataMember]
public virtual Int32? MultiListGroupId { get; set; }
protected SystemTemplate() { }
public SystemTemplate(string title, byte[] templateDoc, string templateDocName, TemplateType templateType, int multiListGroupId)
{
this.Title = title;
this.TemplateDoc = templateDoc;
this.IsSystemTemplate = true;
this.MultiListGroupId = multiListGroupId;
}
}
Now, when I try to call following service method:
List<Template> GetTemplatesByTemplateType(int officeId, int? userId, TemplateType templateType)
I get this error:
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Is it because of the reason that I am trying to return an abstract class?
It runs fine if I try to call this method using unit test.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…