Good morning, folks.
I'm currently writing a distributed app using WCF (updated to Beta2 at last!). We're using the net.tcp binding and controlling both sides of the wire - no need for any interop with other platforms for now.
One of the Operations out services expose has an abstract parameter - it receives (or returns) an IMyInterface parameter. The publisher, naturally fills this in with the required concrete type. Both the interface and the concrete type are marked with [DataContract]
Due to the way the DataContractSerializer works, no type information is sent to the other side of the wire - this is mainly for interop reasons, I am told. This means we had to add [ServiceKnownType] attributes for every type we pass, and this gets quite annoying since we have about 10-15 types that are passed as their abstract representations.
Looking for solutions, I stumbled across the NetDataContractSerializer class, which serializes exactly the same way but also includes the CLR type definition, thus solving my problem exactly. When trying to actually use this serializer, I ran across Aaron Skonnard blog entry where he claims that the use of the NetDataContractSerializer is discouraged and there's no built-in attribute to enable it on a class.
So my questions are:
1) Is the NDCS really discouraged, assuming I control both ends of the pipe
2) If so, why
3) Is the solution offered by Skonnard - writing my own Format attribute - the official and recommended way to use the NDCS
Thanks,
Avner Kashtan

NetDataContractSerializer
M. Aamir Malik
1) Is the NDCS really discouraged, assuming I control both ends of the pipe
[sowmy] Yes
2) If so, why
[sowmys]It requires exact CLR type on both ends. The wire size is significantly larger. Certain types such as collections are serialized as CLR types as opposed repeating elements. This could cause an evil middleman to create instances of types the service did not intend. (Mitigated in a secured channel)
3) Is the solution offered by Skonnard - writing my own Format attribute - the official and recommended way to use the NDCS
[sowmys] It is a nifty technique. There is no recommended or official technique.
FWIW, if adding ServiceKnownTypeAttribute does not work, please check out this post for otherways of providing known types.