Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 651637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:11:02+00:00 2026-05-13T22:11:02+00:00

First, an example of something that works as expected: (all code was executed in

  • 0

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.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:11:03+00:00Added an answer on May 13, 2026 at 10:11 pm

    It’s because the type of wcfChannel is the interface itself:

    >> channel.GetType().FullName
    "MyService.IMyServiceApi"
    
    >> channel.GetType().IsInterface
    true
    
    >> channel.GetType() == typeof(IMyServiceApi)
    true
    

    .GetInterfaces() returns only the interfaces inherited or implemented, but not the interface itself.

    Admittedly, it is unusual for an object instance to actually be of an interface type, but as you mentioned in your comment on the question, the object is actually a transparent proxy. It makes sense for that proxy to be agnostic of the actual interface implementation, and care only about the interface. The fact that .GetType() returns the interface makes the proxy as transparent as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example: First, say I have a Silverlight app with Windowless=true so that I
Is there any Java library that supports hierarchical column? For example (the first three
For example, will the first piece of code perform a full search twice, or
The example program below compiles two in-memory assemblies. The first compilation works fine. The
I need to set/get the cookies stored at first.example while browsing second.example , I
I have a simple question related to one-line programming. First an example: function test(a)
Example: I have two shared objects (same should apply to .dlls). The first shared
Update: giving a much more thorough example. The first two solutions offered were right
Experienced with Rails / ActiveRecord 2.1.1 You create a first version with (for example)
I'm working for the first time with Forms Authentication, I'm using an example from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.