WCF: Attack Of The Generics

time to read 2 min | 209 words

I am trying to learn WCF, and I am simply amazed at the amount of Something<T> that they have all over the place. Yes, strongly typing it a wonderful thing, but I think that they went too far with it. (And I am speaking as someone who used generics to give you compile time errors about misformed database queries!)

Let us take ChannelFactory<T> for instnace, I can't use it without specifying a type parameter. All fine and good, until I need to construct a proxy from its System.Type, in a late bound fashion. Then it starts to get ugly. This is particulary annoying since as far as I can reflect, I am seeing that the underlying ServiceChannelFactory does not use the generic model, so I could make it work with a System.Type object. The problem is that again, someone decided to slap internal on useful types.

This leads to... interesting code, shall we say, when it comes to dealing with ChannelFactory in a generic fashion (i.e, not against a specific service, but against several). This is me after about 30 minutes of starting to play with WCF. I just hate it when I run into brick walls so fast.