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

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -