Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:07:15+00:00 2026-06-11T16:07:15+00:00

I´m getting an WCF Error on Serverside: There was an error while trying to

  • 0

I´m getting an WCF Error on Serverside:

There was an error while trying to serialize parameter http://tempuri.org/:GetUserResult. The InnerException message was ‘Type ‘RoleProxy’ with data contract name RoleProxy:http://schemas.datacontract.org/2004/07/’ is not expected. …

My Problem is, that I dont have any RoleProxy Type, that could be serialized.

I have the following Class:

[DataContract]
[KnownType(typeof(Permission))]
public class Role
{
    protected virtual long _ID { get; set; }

    [DataMember]
    public virtual long ID
    {
        get { return _ID; }
        // zum Test
        set { _ID = value; }
    }
    [DataMember]
    public virtual string Name { get; set; }
    [DataMember]
    public virtual bool IsDefault { get; set; }
    [DataMember]
    public virtual ICollection<Permission> Permissions { get; set; }

    public Role()
    {

    }

    public Role(string name, ICollection<Permission> permissions, bool isDefault = false)
    {
        Name = name;
        Permissions = permissions;
        IsDefault = isDefault;
    }

    public virtual bool HasPermission(Permission perm)
    {
        foreach(Permission permission in this.Permissions)
            if (permission.Equals(perm))
                return true;

        return false;
    }

    public virtual bool Equals(Role other)
    {
        if (ReferenceEquals(null, other)) return false;
        if (ReferenceEquals(this, other)) return true;
        return Equals(other.Name, Name);
    }

    public override bool Equals(object obj)
    {
        if (ReferenceEquals(null, obj)) return false;
        if (ReferenceEquals(this, obj)) return true;
        if (obj.GetType() != typeof(Role)) return false;
        return Equals((Role)obj);
    }

    public override int GetHashCode()
    {
        return Name.GetHashCode();
    }

    public override string ToString()
    {
        return Name;
    }
}

and here is the function i am calling:

[ServiceContract]
[ServiceKnownType(typeof(Role))]
[ServiceKnownType(typeof(User))]
[ServiceKnownType(typeof(Permission))]
[ServiceKnownType(typeof(IList<Role>))]
[ServiceKnownType(typeof(IList<User>))]
[ServiceKnownType(typeof(IList<Permission>))]
public interface ISecurityManager
{
    ...

    [OperationContract]
    User GetUser(string userDomain, string userName);

    ...

}

The Result is received correctly by the server, but there is some serialitation problem which I coulndt find. Any solutions?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:07:16+00:00Added an answer on June 11, 2026 at 4:07 pm

    ORMs such as EF and NHibernate like to create proxy types at runtime that extend the default behaviour. Most regular code won’t care that it has a sub-type (Liskov substitution principle, etc) – but: inheritance aware serializers need to check what object they are actually working with.

    Dealing with dynamic proxy types is a pain; some serializers can handle some proxies (i.e. by not treating the proxy as an unexpected sub-type, but instead serializing it as if it was the base type), but it is by no means universal. The most practical thing to do is to map your data back into a Role instance, to make sure that what you give WCF is the object you told it about. AutoMapper might make a convenient implementation for such.

    As an additional observation, this also means that you Equals code is wrong:

        if (obj.GetType() != typeof(Role)) return false;
        return Equals((Role)obj);
    

    should be:

        return Equals(obj as Role);
    

    (noting that Equals(Role) already handles the null case correctly for us)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am getting following error message on calling WCF service: The formatter threw an exception
I am getting the following error when trying to use the WCF Test Client
I'm getting the following exception trying to pass an object through wcf: There was
I'm getting this error trying to implement the sample WCF Dependency Injection with Unity.
I am getting the following error when trying to access a WCF service. Could
I am getting the below error message in my WCF service. Below is my
I am getting the above error when trying to request data across WCF 4
I'm getting the following error when trying to connect to a WCF web service:
I am getting the below error when trying to access a WCF Silverlight enabled
Good Day Everyone... I’m getting an unexpected WCF error complaining of Known Types which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.