1
ChannelFactory<T> factory = ...;

var channel = factory.CreateChannel();

channel.GetType().IsInterface; // true -> what? an instance of interface?

channel is IClientChannel; // true
channel.GetType().GetInterfaces(); // empty array -> so does it really implement IClientChannel or does it not?

Please take a look at the provided code sample.
I know that WCF dynamically compiles __TransparentProxy but how can it hide a type of channel so that object looks like an instance of an interface?
How could one obtain real type of channel and list of interfaces it actually implements?

user3608068
  • 424
  • 2
  • 13
  • What does channel.GetType() return? – Russ Jan 14 '21 at 14:34
  • Channel is indeed an interface, it is the interface of WCF service. In my opinion, if a channel is created, the client should have the base address of the WCF side and some configuration information at this time, and then the WCF service can be called remotely through some methods defined in the channel interface. – Ding Peng Jan 15 '21 at 06:17

1 Answers1

0

AFAIK

channel is an instance of an interface, not a class. At least the way the code sees it. Though there is, presumably, an actual class there, in this code it's considered something like an instance of an interface.

That interface doesn't implement other interfaces so GetInterfaces() is empty.

About how to get the actual class behind the interface - that should be a separate question. (And, I don't know how to do it.) But check first - it looks like it's been asked before here.

ispiro
  • 26,556
  • 38
  • 136
  • 291
  • 1
    For more reading: https://stackoverflow.com/a/30915147/1086121 (I don't know if this is how WCF does it) – canton7 Jan 14 '21 at 14:34