How can I create DynamicProxy for the WCF proxy that ChannelFactory <T> creates?

I am using ChannelFactory to create a runtime proxy for the WCF service. I would like to use the Castle DynamicProxy project to create a dynamic proxy server on top of the WCF proxy server so that I can intercept calls and perform impersonation.

I get an error message when I try to do this ... error message:

The 'this' type cannot be the interface itself.

My code is this (where T is the interface of the service contract):

var generator = new ProxyGenerator();

return (T)generator.CreateInterfaceProxyWithTarget(typeof(T), channel, 
    new[] { new ImpersonationInterceptor() } );

The problem should be related to the fact that the service proxy generated by ChannelFactory is generated at runtime, but is there any way around this problem?

+3
1

- - WCF Facility, WCF Castle DynamicProxy.

, - -, - ... , , .

0

Source: https://habr.com/ru/post/1755526/


All Articles