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

  • Home
  • SEARCH
  • 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 9013881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:22:39+00:00 2026-06-16T03:22:39+00:00

We are using a base class for all of our Response DTO’s in our

  • 0

We are using a base class for all of our Response DTO’s in our application. The class has the following signature:

[Serializable]
public abstract class ResponseBase
{
    public bool Successful { get; set; }
    public List<ResponseMessage> Messages { get; set; }

    //...Other code...
}

The Messages collection can be any of the following types:

[Serializable]
[XmlInclude(typeof(DebugMessage))]
[XmlInclude(typeof(InfoMessage))]
[XmlInclude(typeof(ValidationMessage))]
[XmlInclude(typeof(WarnMessage))]
[XmlInclude(typeof(RecoverableFaultMessage))]
[XmlInclude(typeof(FatalFaultMessage))]
public abstract class ResponseMessage
{
    //..Other code...
}

With concrete versions of:

[Serializable]
public class DebugMessage : ResponseMessage
{
    public override MessageType MessageType { get { return MessageType.Debug; } }
}
[Serializable]
public class InfoMessage : ResponseMessage
{
    public override MessageType MessageType { get { return MessageType.Info; } }
}
[Serializable]
public class ValidationMessage : ResponseMessage
{
    public override MessageType MessageType { get { return MessageType.Validation; } }
}
[Serializable]
public class WarnMessage : ResponseMessage
{
    public override MessageType MessageType { get { return MessageType.Warn; } }
}
[Serializable]
public class RecoverableFaultMessage : ResponseMessage
{
    public override MessageType MessageType { get { return MessageType.RecoverableFault; } }
}
[Serializable]
public class FatalFaultMessage : ResponseMessage
{
    public override MessageType MessageType { get { return MessageType.FatalFault; } }
}

All DTO Response objects inherit from ResponseBase however even with the following ServiceKnownTypes on the WCF Contract

[ServiceKnownType(typeof(ResponseBase))]
[ServiceKnownType(typeof(ResponseMessage))]
[ServiceKnownType(typeof(List<ResponseMessage>))]
[ServiceKnownType(typeof(DebugMessage))]
[ServiceKnownType(typeof(InfoMessage))]
[ServiceKnownType(typeof(ValidationMessage))]
[ServiceKnownType(typeof(WarnMessage))]
[ServiceKnownType(typeof(RecoverableFaultMessage))]
[ServiceKnownType(typeof(FatalFaultMessage))]
[ServiceKnownType(typeof(List<DebugMessage>))]
[ServiceKnownType(typeof(List<InfoMessage>))]
[ServiceKnownType(typeof(List<ValidationMessage>))]
[ServiceKnownType(typeof(List<WarnMessage>))]
[ServiceKnownType(typeof(List<RecoverableFaultMessage>))]
[ServiceKnownType(typeof(List<FatalFaultMessage>))]

When we load a Message into the ResponseBase Messages collection the following exception gets thrown:

Error in line 1 position 906. Element
‘http://schemas.datacontract.org/2004/07/CX.Framework.Common.BaseTypes:ResponseMessage&#8217;
contains data from a type that maps to the name
‘http://schemas.datacontract.org/2004/07/CX.Framework.Common.BaseTypes:WarnMessage&#8217;.
The deserializer has no knowledge of any type that maps to this name.
Consider using a DataContractResolver or add the type corresponding to
‘WarnMessage’ to the list of known types – for example, by using the
KnownTypeAttribute attribute or by adding it to the list of known
types passed to DataContractSerializer.

We have done everything from ServiceKnownType to XMLInclude on the derived types. I’m at a bit of a loss as to how to resolve this and would appreciate any assistance anyone can provide.

  • 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-16T03:22:40+00:00Added an answer on June 16, 2026 at 3:22 am

    A few things:

    1) [XmlInclude] will have no effect on the DataContractSerializer, it’s only used by the XmlSerializer.

    2) As the commenter “flem” suggested, I would use [KnownType] directly on ResponseMessage instead of [ServiceKnownType] on the service.

    3) I don’t remember whether the DataContractSerializer even looks for [KnownType] on [Serializable] types. At least for testing purposes for now, try making your types [DataContract] instead (and attribute the data members with [DataMember]) if #2 above doesn’t help.

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

Sidebar

Related Questions

I am faced with the following conundrum: Our software has an abstract base class
I have a base class, defined as below (I'm also using DevExpress components): public
I am creating an ASP.NET MVC3 application using NHIBERNATE. I have a base class
Let's say I have the following class hierarchy (base interface included): IAction -> (abstract)
I have the following data structure: //property Notification abstract class BindableBase { } //base
In a design of a class hierarchy, I'm using an abstract base class that
We're using NLog for logging in an C# MVC3 web application. All of our
We are using a base class where we set the background picture. That code
For my tests I'm using a base class MyTestBase defining a method setup() that
I started using Base.js for a class inheritance. In Base.js a class should be

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.