Why doesn't interface inheritance work when writing shell extensions in c#?

Posted by Factor Mystic on Stack Overflow See other posts from Stack Overflow or by Factor Mystic
Published on 2010-04-18T02:52:57Z Indexed on 2010/04/18 3:43 UTC
Read the original article Hit count: 368

According to this article about writing shell extensions in .Net, inheriting the shell interfaces as you might naturally do when writing code doesn't work. I've observed this in my own code as well.

Doesn't work:

public interface IPersist {
    // stuff specific only to IPersist
}

public interface IPersistFolder : IPersist {
    // stuff specific only to IPersistFolder
}

Does work:

public interface IPersistFolder {
    // stuff specific to IPersist only
    // stuff specific to IPersistFolder only
}

The article notes this fact:

Lo and behold, it worked! Notice that I've abandoned any idea that IPersistFolder is inherited from anything at all and just included the stubs from IPersist right in its definition. In all candor, I can't tell you why this is but it definitely works just fine and shouldn't give you any problems.

So my I'll ask the question this guy didn't know; why didn't the original code work?

© Stack Overflow or respective owner

Related posts about shell-extensions

Related posts about interface-inheritance