c# - WCF Multiple Base Classes in one interface? -
i wanted know if possible utilize more 1 base of operations class in 1 interface. face problem using 2 (and there more) base of operations classes 1 interface. using first 1 no problem @ all, when seek work sec one, not work.
i write downwards code in short
[servicecontract(namespace = "http://bla.servicemodel.samples", sessionmode = sessionmode.required)] [serviceknowntype(typeof(observablecollection<models.model1>))] [serviceknowntype(typeof(observablecollection<models.model2>))] public interface iservice { [operationcontract] observablecollection<models.model1> accessmodel1(); [operationcontract] observablecollection<models.model2> accessmodel2(string group); }
after connecting client, creating collection of model1 works fine. when seek create collection of model2, crashes. inner exception "an existing connection forcibly closed remote host."
model1 , 2 contain different information, have same structure.
is there fundamentally error or else?
if need farther information, welcome!
update
i post model classes. maybe blind , cant see error.
[datacontract] public class model2 { private string status; private string name; private string telephone; public model2(string sstatus, string sname, string stelephone) { status = sstatus; name = sname; telephone = stelephone; } [datamember(isrequired = true, order = 0)] public string status { { homecoming status; } set { status = value; } } [datamember(isrequired = true, order = 1)] public string name { { homecoming name; } set { name = value; } } [datamember(isrequired = true, order = 2)] public string telephone { { homecoming telephone; } set { telephone = value; } } } internal class model2builder: observablecollection<model2> { public model2builder(string group) : base() { seek { datatable dt = new database().getmodel2data(group); foreach (datarow row in dt.rows) { add(new model2(row[0].tostring(), row[1].tostring(), row[2].tostring())); } dt.dispose(); } grab (exception ex) { //code log... } } }
on model classes have tried adding parameterless constructors - i'm pretty sure info contract serializer requires requires parameterless constructors, i.e.
[datacontract] public class model2 { private string status; private string name; private string telephone; public model2(){} public model2(string sstatus, string sname, string stelephone) { status = sstatus; name = sname; telephone = stelephone; } ...etc
c# wcf datacontract
No comments:
Post a Comment