WCF Knowntypes – Easy WCF
Skip to content

WCF Knowntypes

When a message is sent over network, using WCF, it is serialized. When this code is recieved, the WCF API parses the XML and tries to create C# objects.When client sends an derived instance of the class then how it knows which class is instantiated?

The KnownType attribute informs the WCF if it can receive the derived instance of the class.

There are 4 different ways to associate KnownType in WCF.

  • KnownType Attribute in Base type
    • This is global and all service and operation contract should respect known type.

  • Associate Service knowntype Attribute in service contract
    • The scope for this knownType is all operation contract within this service only

  • Associate Service Knowntype Attribute in Specific Operation Contract
    • The scope for KnownType would be only the operation contract that is associated with Service KnownType

  • Associate KnownType in Configuration file
    • This is similar to associating KnownType with Base type.The scope is global.

Define KnownType in app.config:

© 2015, admin. All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *