[ERROR] Inconsistent accessibility---inconsistent accessibility

Source: Internet
Author: User

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;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.