asp.net - Unable to pass custom datatype as parameter to wcf service -
i created 1 custom library project , have employee class hold employee information.
namespace test.samplelib { public class employee { public string employeename { get; set; } public double employeesalary {get; set; } } }
i added employee class library wcf service
public test.samplelib.employee getdatausingdatacontract(test.samplelib.employee composite) { return composite; }
i tried consume service , access method getdatausingdatacontract()
servicereference1.service1client objserviceref = new servicereference1.service1client(); test.samplelib.employee objemployee = new samplelib.employee(); objemployee.employeename = "kumar"; objemployee.employeesalary = 30000; objserviceref.getdatausingdatacontract(objemployee); //gives errror
the error is
'argument 1: cannot convert 'test.samplelib.employee' 'test.web.servicereference1.employee'
you need have [datacontract]
, [datamember]
attributes on custom data types , properties want expose.
[datacontract] public class employee { [datamember] public string employeename { get; set; } [datamember] public double employeesalary {get; set; } }
Comments
Post a Comment