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 6209245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:56:58+00:00 2026-05-24T05:56:58+00:00

I have a webservice with a method that takes a parameter of abstract base

  • 0

I have a webservice with a method that takes a parameter of abstract base type Specification<TDomainModel> as parameter. I realize that WCF don’t know how to de-/serialize this without specifying known types. But when I try to specify them, I still get this exception:

There was an error while trying to serialize parameter http://myproject.org:specification. The InnerException message was ‘Type ‘MyProject.DomainModel.WebSnapshot.WebSnapshotSpecification’ with data contract name ‘WebSnapshotSpecification:http://schemas.datacontract.org/2004/07/MyProject.DomainModel.WebSnapshot&#8217; is not expected. Add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

If anyone can see where I have missed something, it would be very much appreciated 🙂
The classes looks as follows:

WebSnapshotRepositoryService:

[ServiceContract(Namespace = "http://myproject.org")]
[ServiceKnownType(typeof(Specification<WebSnapshot>))]
[ServiceKnownType(typeof(WebSnapshotSpecification))]
public class WebSnapshotRepositoryService
{
    [OperationContract]
    public IEnumerable<WebSnapshot> Get(Specification<WebSnapshot> specification)
    {
        // Code here.
    }
}

and WebSnapshotSpecification:

public class WebSnapshotSpecification : Specification<WebSnapshot>
{
    public override Expression<Func<WebSnapshot, bool>> IsSatisfiedByExpression()
    {
        return (t) => true;
    }
}

which is a specification of WebSnapshot:

[DataContract(IsReference = true, Name = "WebSnapshot", Namespace = "MyProject.DomainModel.WebSnapshot")]
public class WebSnapshot
{
    [DataMember(Order = 1)]
    public virtual string Name { get; set; }
    [DataMember(Order = 2)]
    public virtual string PictureFilePath { get; set; }
    [DataMember(Order = 3)]
    public virtual int PictureHeight { get; set; }
    [DataMember(Order = 4)]
    public virtual int PictureWidth { get; set; }
}

finally, here is Specification<TDomainModel>:

public abstract class Specification<TDomainModel>
{
    public virtual bool IsSatisfiedBy(TDomainModel domainObject)
    {
        return IsSatisfiedByExpression().Compile().Invoke(domainObject);
    }

    public virtual TDomainModel AssembleObject()
    {
        return Activator.CreateInstance<TDomainModel>();
    }

    public abstract Expression<Func<TDomainModel, bool>> IsSatisfiedByExpression();
}
  • 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-05-24T05:57:01+00:00Added an answer on May 24, 2026 at 5:57 am

    It seems like you are trying to send a WebSnapshotSpecification class instance to the service and are expecting WCF to serialize/deserialize the IsSatisfiedByExpression method it contains. That scenario is not supported in WCF. If the WebSnapshotSpecification class had some properties then those will be serialized/deserialized but methods are never part of a WCF implicit or explicit DataContract definition.

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

Sidebar

Related Questions

I have an method that takes in an observable collection (returned from a webservice)
I have a grails webservice that takes a binary file as a parameter. This
I have a WCF service, in it i have a method that takes a
I have a webservice method that reads a photo and returns its byte data.
I have created a console application that calls a method on a webservice. I
I have a web service method that takes a network login (string) as a
We have a legacy WSE3 ASP.Net webservice here that defines a method GetFileContent(string fileName)
I have a util class (C#) where I have a static method that takes
I have a Web Service with Just one Web Method that returns a boolean
I have some ASP.NET page and webservice WebMethod() methods that I'd like to add

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.