In the design of the data contract class, and use its parameters to implement client and server data interaction, edit the service class, the following error occurred:
Error 1 inconsistent accessibility:parameter type ' wcfservice.userdatacontract ' is less accessible than method ' Wcfservic E.iwcfservice.addnewuser (wcfservice.userdatacontract) ' E:\CodesVs2008\WCFServiceDataContractFrankXuLei\ Wcfservicefrankxulei\wcfservice\wcfservice.cs Wcfservice
Other similar error messages:
Error 2 inconsistent accessibility:return type ' wcfservice.userdatacontract ' is less accessible than method ' wcfservice.i Wcfservice.getuserbyname (String) ' E:\CodesVs2008\WCFServiceDataContractFrankXuLei\WCFServiceFrankXuLei\ Wcfservice\wcfservice.cs Wcfservice
Solution:
This error is due to the inconsistency of the Access property settings of the data contract class to the service contract Access property, the service contract interface's access behavior public, and the service class is public, and the data contract class has no access attribute for life.
We add the data contract class to the Public keyword. The sample code is as follows:
[datacontract]//Data Contract Property declaration
public class Userdatacontract
{
[DataMember (Name = ' UserName ') ]//data member tag, support alias definition
public string Name
{
get;
Set
}
[DataMember (Name = "UserEmail")]//data member tag, support alias definition
public string Email
{
Get;
Set;
}
[datamember]//data member Tag
public string Mobile
{
get; set;
}
//No [DataMember] declaration, no serialization of
public string address
{
Get
Set;
}
}