I am using ChannelFactory to create a proxy at run-time for a WCF service. I would like to use the DynamicProxy Castle project to create a dynamic proxy on top of the WCF proxy so that I can intercept calls and do impersonation.
I'm getting an error when I try this though... the error message is:
'this' type cannot be an interface itself.
My code is this (where T is a service contract interface):
var generator = new ProxyGenerator();
return (T)generator.CreateInterfaceProxyWithTarget(typeof(T), channel,
new[] { new ImpersonationInterceptor() } );
The problem must have to do with the fact that the service proxy generated by ChannelFactory is generated at runtime, but is there any way around this problem?