First, an example of something that works as expected: (all code was executed in VS2008 immediate window)
25 is IComparable
>> true
25.GetType().GetInterfaces()
>> {System.Type[5]}
>> [0]: {Name = "IComparable" FullName = ...
>> [1]: {Name = "IFormattable" FullName = ...
>> ...
So far so good. Now let's try on an object where the interface is inherited via a base type:
class TestBase : IComparable
{
public int CompareTo(object obj) { throw new NotImplementedException(); }
}
class TheTest : TestBase { }
In the immediate window:
(new TheTest()) is IComparable
>> true
(new TheTest()).GetType().GetInterfaces()
>> {System.Type[1]}
>> [0]: {Name = "IComparable" FullName = "System.IComparable"}
No surprises here either. How come the following code doesn't show any interfaces then:
wcfChannel = ChannelFactory<IMyServiceApi>.CreateChannel(binding, endpointAddress);
wcfChannel is IMyServiceApi && wcfChannel is ICommunicationObject
>> true
typeof(IMyServiceApi).IsInterface && typeof(ICommunicationObject).IsInterface
>> true
wcfChannel.GetType().GetInterfaces()
>> {System.Type[0]}
How can all of the above be true at the same time?
(edit: added wcfChannel is ICommunicationObject
above, which is at this time unexplained by the answer that explains how wcfChannel is IMyServiceApi
is true.)