known-types

How do you configure WCF known types programmatically?

My client/server application is using WCF for communication, which has been great. However one shortcoming of the current architecture is that I must use known type configuration for certain transmitted types. I'm using an in-house Pub/Sub mechanism and this requirement is unavoidable. The problem is that it's easy to forget to add th...

How to specify a WCF known type in config that is generic?

I have a type, let's call it Data<TKey>. I also have a WCF service contract that accepts a type (lets call it Wrapper) with a property of type Object (for reasons I won't go into, this isn't optional). [DataContract] public class Data<TKey> { ... } [DataContract] public class Wrapper { [DataMember] public object DataItem { get...

Declaring Known Types for data contracts in different assemblies

I have a method in a WCF service which returns a complex type (myComplexResult), which includes as one of its members a List (Of Common.myBaseClass). I want this list to hold items which can variously be of type Foo.myClass1 and Bar.myClass2, both of which inherit from Common.myBaseClass. Note that all of these classes are defined in d...

DataContractSerializer, KnownType and inheritance

I've read many articles about known types and i belive my example should work. But it doesn't. I'm getting the following exception on deserialization and don't understand why: Error in line 1 position 2. Expecting element 'A' from namespace 'http://schemas.datacontract.org/2004/07/ConsoleApplication2'.. Encountered 'Element' with name ...

How to add service known types from external config file

Hello, I am having difficulty understanding how to exactly go about adding known types; for WCF, from a configuration file that is external to my wcf. I found an example of how to set the configuration file up, however, I am a bit confused as to the way the file is set up and I am not sure as to how I am actually supposed to call this ...

WCF contracts - namespaces and SerializationExceptions

I am using a third party web service that offers the following calls and responses http://api.athirdparty.com/rest/foo?apikey=1234 <response> <foo>this is a foo</foo> </response> and http://api.athirdparty.com/rest/bar?apikey=1234 <response> <bar>this is a bar</bar> </response> This is the contract and supporting types I wrot...

What is the difference in WCF when using KnownType and ServiceKnownType?

I have a service that returns an array of animal but the list can contain cats, dogs, etc, which all extend animal. I know I need to use either the KnownType or ServiceKnownType attribute, and on the entity class or the service class, respectively. What is the difference between the 2 attributes? I prefer the ServiceKnownType because it...

WCF Exception: Cannot add to list of known types

Good Day Everyone... I’m getting an unexpected WCF error complaining of “Known Types” which are similarly named, but in different name-spaces (see error below). ...please keep in mind I'm still experimenting with all this. Also… I already understand the nature of regular web-services FORCES you to flatten your object hierarchy, but e...