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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:09:26+00:00 2026-05-12T12:09:26+00:00

I have the following: [ServiceContract] [ServiceKnownType(typeof(ActionParameters))] [ServiceKnownType(typeof(SportProgram))] [ServiceKnownType(typeof(ActionResult<SportProgram>))] public interface ISportProgramBl { [OperationContract] IActionResult<ISportProgram>

  • 0

I have the following:

[ServiceContract]
[ServiceKnownType(typeof(ActionParameters))]
[ServiceKnownType(typeof(SportProgram))]
[ServiceKnownType(typeof(ActionResult<SportProgram>))]
public interface ISportProgramBl  
{
    [OperationContract]
    IActionResult<ISportProgram> Get(IActionParameters parameters);
}

When I run the Get method I get the following error:

There was an error while trying to serialize parameter http://tempuri.org/:GetResult. The InnerException message was ‘Type ‘PPS.Core.DomainModel.Support.Action.ActionResult`1[ [PPS.Core.DomainModel.SportProgram.ISportProgram, PPS.Core.DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]’ with data contract name ‘ActionResultOfanyType: http://schemas.datacontract.org/2004/07/PPS.Core.DomainModel.Support.Action‘ 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.’. Please see InnerException for more details.

From this error I can see that it can resolve ActionResult but it can’t resolve ISportProgram even though I have ServiceKnownType(typeof(ActionResult < SportProgram >)) on my service interface…

Note this is the Reference stub that is generated looks like this, so I can see that the known types are being brought across correctly:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="SportProgramStb.ISportProgramBl")]
public interface ISportProgramBl {

    [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISportProgramBl/Get", ReplyAction="http://tempuri.org/ISportProgramBl/GetResponse")]
    [System.ServiceModel.ServiceKnownTypeAttribute(typeof(PPS.Core.DomainModel.SportProgram.SportProgram))]
    [System.ServiceModel.ServiceKnownTypeAttribute(typeof(PPS.Core.DomainModel.Support.Action.ActionParameters))]
    [System.ServiceModel.ServiceKnownTypeAttribute(typeof(PPS.Core.DomainModel.Support.Action.ActionResult<PPS.Core.DomainModel.SportProgram.SportProgram>))]
    object Get(object parameters);
}

Why is this going wrong???? Note its getting through the WCF service correctly… but it throws the exception when the result is returned.

Lastly ActionResult looks like this:

public interface IActionResult<T> 
{
    T Result { get; set; } 
}

Cheers
Anthony

  • 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-12T12:09:26+00:00Added an answer on May 12, 2026 at 12:09 pm

    Well, I think this is another case of the SOA vs. OOP “impedance mismatch”. The two world are quite separate.

    In WCF, all that is being passed from the client to the server is passed as serialized messages – no references are being used.

    This means: everything you want to serialize on the client, send it across to the server, and deserialize it and use it there, must be concrete – you cannot pass around interfaces, you cannot use “non-resolved” generics – you need to spell it out. Basically, all that’s being passed from client over the wire to the server must be expressable in XML schema.

    This has lots of implications:

    • no interfaces – you cannot pass around interfaces – you need to work with concrete types
    • no “automatic” inheritance – you cannot just define a base class and pass around derived classes based on it – those need to be specificied too (that’s what the ServiceKnownType attribute is for)
    • no automatic generics – again, you need to use concrete types instead

    This may sound like a lot of restrictions – but it’s because WCF is using all message-based communication – it cannot deal with refereces, inheritance, generics etc. – you need to spell it out.

    So I don’t really have an answer for you per se – I just think you need to rethink your strategy and change the way your client and server are exchanging information over WCF.

    Marc

    PS: I did some more research, and contrary to all my understanding, there seems to be a way to serialize anything that’s based on an interface and/or abstract base class across the wire, as long as you can be sure it’s always only .NET on either end of the wire (i.e. it’s not interoperable with e.g. Java).

    See Aaron Skonnard blog post on the NetDataContractSerializer and another blog post and yet another showing how to use the NetDataContractSerializer to be able to pass around things like IPerson as parameters to your methods.

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

Sidebar

Related Questions

I have defined the following Interface [ServiceContract] public interface IHealthProducts { [OperationContract()] ResponseClass OrderSelfSignedHealthCertificate();
I have the following web service function- [ServiceContract] public interface ITest { [OperationContract] double
I have the following ServiceContract: [ServiceContract(Namespace = http://WebAdmin.Services.AdministrativeService, Name = AdministrativeService)] public interface IAdministrativeService
Imagine I have the following, standard WCF, code : [ServiceContract] interface ICustomerService { [OperationContract]
please check the below example namespace GServices { [ServiceKnownType(typeof(SearchType))] [ServiceContract(SessionMode = SessionMode.Allowed)] public interface
I have defined the following interface in F# [<ServiceContract>] type ICarRentalService = [<OperationContract>] abstract
I have a ServiceContract on the server like this: [ServiceContract] public interface ICheckService {
I have the following classes: [DataContract] [KnownType(typeof(SpecifiedItemCollection))] public class ItemCollection<T> : IEnumerable where T
I have a ServiceContract which returns dynamic type and looks like following: public dynamic
I have a simple WCF logging service.. namespace WCFServiceLibrary { [ServiceContract] public interface ILog

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.