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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:39+00:00 2026-05-23T09:04:39+00:00

I got this problem, The deserializer has no knowlege of any type that maps

  • 0

I got this problem,
“The deserializer has no knowlege of any type that maps to this contract”
After googling, I reached this post

The deserializer has no knowlege of any type that maps to this contract

where the answer says, the base class have to declare “KnownTypes” like
[DataContract, KnownType(typeof(Subclass)) …],

If I have to declare this in my parent class, [DataContract, KnownType(typeof(Subclass))], doesn’t it break the principles of OO Design that parent class doesn’t have to know about subclass?

What is the right way of doing this?

  • 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-23T09:04:39+00:00Added an answer on May 23, 2026 at 9:04 am

    The serializer is designed in a way that, if it serializes an object, it should be able to read it back. If you attempt to serialize an object with a declared type of ‘Base’, but an actual type of ‘Derived’ (see example below), if you want to be able to read back from the serialized object an instance of ‘Derived’, you need to somehow annotate the XML that the instance is not of the type of which it was declared.

    [DataContract]
    public class MyType
    {
        [DataMember]
        public object obj = new Derived();
    }
    

    The serialized version of the type would look something like the XML below:

    <MyType>
      <obj actualType="Derived">
        <!-- fields of the derived type -->
      </obj>
    </MyType>
    

    When the type is being deserialized, the serializer will look at the “actualType” (not actual name) attribute, and it will have to find that type, initialize it, and set its properties. It’s a potential security issue to let the serializer (with in Silverlight lives is a trusted assembly and has more “rights” than the normal user code) to create arbitrary type, so that’s one reason for limiting the types which can be deserialized. And based on the design of the serializer (if we can serialize it, we should be able to deserialize it), the serialization fails for that reason as well.

    Another problem with that is that the serialized data is often used to communicate between different services, in different computers, and possibly with different languages. It’s possible (and often it is the case) that you have a class in a namespace in the client which has a similar data contract to a class in the server side, but they have different names and / or reside in different namespaces. So simply adding the CLR type name in the “actualType” attribute won’t work in this scenario either (the [KnownType] attribute helps the serialzier map the data contract name / namespace to the actual CLR type). Also, if you’re talking to a service in a different language / platform (i.e., Java), CLR type names don’t even make sense.

    Another more detailed explanation is given at the post http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,a3775eb1-b441-43ad-b9f1-e4aaba404235.aspx – it talks about [ServiceKnownType] instead of [KnownType], but the principles are the same.

    Finally, about your question: does it break that OO principle? Yes, that principle is broken, that’s a price to pay for being able to have lose coupling between the client and services in your distributed (service-oriented) application.

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

Sidebar

Related Questions

Has anyone else run into this problem before? I've got a method that calls
I got this problem after deploying my web package to IIS: HTTP Error 500.19
Ive got this problem: Line 20 (LOOT_FromContainer(container) I need that to use as Invoke
Hi I got this problem when accessing database: AttributeError at /renderForm/0 'function' object has
I've got this problem that I can't solve. Partly because I can't explain it
I've got this problem that It always hit the PropertyAccessException when trying to saveOrUpdate();
Guys, I've got this problem that I searched almost everywhere (maybe I don't know
I got this problem that I can't just solve algorithmically. Let's say i have
I got this problem with AVAudioRecorder not working for me, at least from what
I've got this problem for a while now and I cannot find a solution

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.