WCF Service and Inconsistent accessibility

I cannot understand what is wrong. Mistake:"Inconsistent accessibility: return type 'Library.ServiceReference1.Author[]' is less accessible than method 'Library.Funcs.GetAuthorsList()'"

//class in DLL    
[DataContract]
public class Author
{
    [DataMember]
    private string FN, N, P;
    [OperationContract]
    public string GetFamilyName()
    {
        return FN;
    }
    [OperationContract]
    public string Name()
    {
        return N;
    }
    [OperationContract]
    public string Patronymic()
    {
        return P;
    }
    public Author(string familyName, string name, string patronymic)
    {
        FN = familyName;
        N = name;
        P = patronymic;
    }
}
//in service
public Author[] GetAuthorsList()
    {
        return DB.Singleton.GetAuthorsList().ToArray();
    }

Answers


Why do you have [OperationContract] attributes in your DataContract class, I believe those are not valid outside of a ServiceContract decorated class?

If you define read only properties instead of those methods it should work

[DataContract]
public class Author
{
    [DataMember]
    private string FN, N, P;

    public string FamilyName
    {
        get { return FN; }
    }

    public string Name
    {
        get { return N; }
    }

    public string Patronymic
    {
        get { return P; }
    }

    public Author(string familyName, string name, string patronymic)
    {
        FN = familyName;
        N = name;
        P = patronymic;
    }
}

Need Your Help

Using O-Profile with Linux RedHat OS => conflict with NMI watchdog

linux redhat oprofile

I was trying to run o-profile (a profiling program for linux) and kept getting an error while starting saying something like counter 0 was being use by 'NMI watchdog'. Is NMI part of the OS or is i...

ActionResult cast parameter base class to derived class

c# asp.net-mvc casting derived-class

I've written a base class and some classes which derive from it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.