Interface method missing from base class… COM?











up vote
1
down vote

favorite












I'm working with Microsoft's EnvDTE Assemblies and I noticed the methods/properties unique to the newest Interfaces aren't included in the base type. For example, the AddFromTemplateEx method.



DTE dte = (DTE) ((IServiceProvider) Host).GetCOMService(typeof(DTE));
Solution4 solution = (Solution4)dte.Solution; //Solution4 is an interface
WriteLine(solution.GetType().FullName);


The above code writes out:



EnvDTE.SolutionClass


Yet the EnvDTE.SolutionClass does not contain an implementation for AddFromTemplateEx(). I'm confused because I can still use the methods from the Solution4 interface, but I don't see how if they aren't implemented in the SolutionClass.



What magic is happening here? The SolutionClass is MarshaledbyRef, its base type is System._ComObject... Is this something to do with the Interface implementations existing on the underlying COM object and not the base type?










share|improve this question




















  • 1




    It would be better if Microsoft did not document these XxxxClass types. But they are a bit too obvious in a c# or vb.net project, so they kinda have to. They are "fake" classes, auto-generated by the type library importer. A COM coclass does not expose its implementation at all, it only lists what interfaces it implements. One is special, the default interface, Xxxx. The fake class merges the members of all the interfaces. A consequence of auto-generating it is that the fake class looks different in different VS versions. And that the docs can't keep up.
    – Hans Passant
    Nov 10 at 13:28










  • Thanks so much! What do you mean by XxxxClass type?
    – FakeSaint
    Nov 10 at 19:55






  • 1




    Xxxx == Solution in your question. It is the default interface, goes back to 2002. The actual class that implements it is written in C++, not visible at all. Today it also implements the Solution2, Solution3 and Solution4 interfaces. New features getting added over the years.
    – Hans Passant
    Nov 10 at 20:50










  • Hmm thank you lots to think about. You could move this to answer if you like :)
    – FakeSaint
    Nov 10 at 21:28






  • 1




    Just more of the way COM is special. They made the syntax look familiar to C# programmers. What really happens is that the CLR calls IUnknown.QueryInterface(). The actual C++ class object you created, more up to date than the SolutionClass wrapper you are looking at, knows about it so is happy to return the interface pointer. This interface-based programming paradigm is core to the way Microsoft writes its code. Follow the links at the bottom of the linked article to learn more about it.
    – Hans Passant
    Nov 10 at 21:56

















up vote
1
down vote

favorite












I'm working with Microsoft's EnvDTE Assemblies and I noticed the methods/properties unique to the newest Interfaces aren't included in the base type. For example, the AddFromTemplateEx method.



DTE dte = (DTE) ((IServiceProvider) Host).GetCOMService(typeof(DTE));
Solution4 solution = (Solution4)dte.Solution; //Solution4 is an interface
WriteLine(solution.GetType().FullName);


The above code writes out:



EnvDTE.SolutionClass


Yet the EnvDTE.SolutionClass does not contain an implementation for AddFromTemplateEx(). I'm confused because I can still use the methods from the Solution4 interface, but I don't see how if they aren't implemented in the SolutionClass.



What magic is happening here? The SolutionClass is MarshaledbyRef, its base type is System._ComObject... Is this something to do with the Interface implementations existing on the underlying COM object and not the base type?










share|improve this question




















  • 1




    It would be better if Microsoft did not document these XxxxClass types. But they are a bit too obvious in a c# or vb.net project, so they kinda have to. They are "fake" classes, auto-generated by the type library importer. A COM coclass does not expose its implementation at all, it only lists what interfaces it implements. One is special, the default interface, Xxxx. The fake class merges the members of all the interfaces. A consequence of auto-generating it is that the fake class looks different in different VS versions. And that the docs can't keep up.
    – Hans Passant
    Nov 10 at 13:28










  • Thanks so much! What do you mean by XxxxClass type?
    – FakeSaint
    Nov 10 at 19:55






  • 1




    Xxxx == Solution in your question. It is the default interface, goes back to 2002. The actual class that implements it is written in C++, not visible at all. Today it also implements the Solution2, Solution3 and Solution4 interfaces. New features getting added over the years.
    – Hans Passant
    Nov 10 at 20:50










  • Hmm thank you lots to think about. You could move this to answer if you like :)
    – FakeSaint
    Nov 10 at 21:28






  • 1




    Just more of the way COM is special. They made the syntax look familiar to C# programmers. What really happens is that the CLR calls IUnknown.QueryInterface(). The actual C++ class object you created, more up to date than the SolutionClass wrapper you are looking at, knows about it so is happy to return the interface pointer. This interface-based programming paradigm is core to the way Microsoft writes its code. Follow the links at the bottom of the linked article to learn more about it.
    – Hans Passant
    Nov 10 at 21:56















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm working with Microsoft's EnvDTE Assemblies and I noticed the methods/properties unique to the newest Interfaces aren't included in the base type. For example, the AddFromTemplateEx method.



DTE dte = (DTE) ((IServiceProvider) Host).GetCOMService(typeof(DTE));
Solution4 solution = (Solution4)dte.Solution; //Solution4 is an interface
WriteLine(solution.GetType().FullName);


The above code writes out:



EnvDTE.SolutionClass


Yet the EnvDTE.SolutionClass does not contain an implementation for AddFromTemplateEx(). I'm confused because I can still use the methods from the Solution4 interface, but I don't see how if they aren't implemented in the SolutionClass.



What magic is happening here? The SolutionClass is MarshaledbyRef, its base type is System._ComObject... Is this something to do with the Interface implementations existing on the underlying COM object and not the base type?










share|improve this question















I'm working with Microsoft's EnvDTE Assemblies and I noticed the methods/properties unique to the newest Interfaces aren't included in the base type. For example, the AddFromTemplateEx method.



DTE dte = (DTE) ((IServiceProvider) Host).GetCOMService(typeof(DTE));
Solution4 solution = (Solution4)dte.Solution; //Solution4 is an interface
WriteLine(solution.GetType().FullName);


The above code writes out:



EnvDTE.SolutionClass


Yet the EnvDTE.SolutionClass does not contain an implementation for AddFromTemplateEx(). I'm confused because I can still use the methods from the Solution4 interface, but I don't see how if they aren't implemented in the SolutionClass.



What magic is happening here? The SolutionClass is MarshaledbyRef, its base type is System._ComObject... Is this something to do with the Interface implementations existing on the underlying COM object and not the base type?







c# .net visual-studio t4 envdte






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 5:11

























asked Nov 10 at 4:07









FakeSaint

636




636








  • 1




    It would be better if Microsoft did not document these XxxxClass types. But they are a bit too obvious in a c# or vb.net project, so they kinda have to. They are "fake" classes, auto-generated by the type library importer. A COM coclass does not expose its implementation at all, it only lists what interfaces it implements. One is special, the default interface, Xxxx. The fake class merges the members of all the interfaces. A consequence of auto-generating it is that the fake class looks different in different VS versions. And that the docs can't keep up.
    – Hans Passant
    Nov 10 at 13:28










  • Thanks so much! What do you mean by XxxxClass type?
    – FakeSaint
    Nov 10 at 19:55






  • 1




    Xxxx == Solution in your question. It is the default interface, goes back to 2002. The actual class that implements it is written in C++, not visible at all. Today it also implements the Solution2, Solution3 and Solution4 interfaces. New features getting added over the years.
    – Hans Passant
    Nov 10 at 20:50










  • Hmm thank you lots to think about. You could move this to answer if you like :)
    – FakeSaint
    Nov 10 at 21:28






  • 1




    Just more of the way COM is special. They made the syntax look familiar to C# programmers. What really happens is that the CLR calls IUnknown.QueryInterface(). The actual C++ class object you created, more up to date than the SolutionClass wrapper you are looking at, knows about it so is happy to return the interface pointer. This interface-based programming paradigm is core to the way Microsoft writes its code. Follow the links at the bottom of the linked article to learn more about it.
    – Hans Passant
    Nov 10 at 21:56
















  • 1




    It would be better if Microsoft did not document these XxxxClass types. But they are a bit too obvious in a c# or vb.net project, so they kinda have to. They are "fake" classes, auto-generated by the type library importer. A COM coclass does not expose its implementation at all, it only lists what interfaces it implements. One is special, the default interface, Xxxx. The fake class merges the members of all the interfaces. A consequence of auto-generating it is that the fake class looks different in different VS versions. And that the docs can't keep up.
    – Hans Passant
    Nov 10 at 13:28










  • Thanks so much! What do you mean by XxxxClass type?
    – FakeSaint
    Nov 10 at 19:55






  • 1




    Xxxx == Solution in your question. It is the default interface, goes back to 2002. The actual class that implements it is written in C++, not visible at all. Today it also implements the Solution2, Solution3 and Solution4 interfaces. New features getting added over the years.
    – Hans Passant
    Nov 10 at 20:50










  • Hmm thank you lots to think about. You could move this to answer if you like :)
    – FakeSaint
    Nov 10 at 21:28






  • 1




    Just more of the way COM is special. They made the syntax look familiar to C# programmers. What really happens is that the CLR calls IUnknown.QueryInterface(). The actual C++ class object you created, more up to date than the SolutionClass wrapper you are looking at, knows about it so is happy to return the interface pointer. This interface-based programming paradigm is core to the way Microsoft writes its code. Follow the links at the bottom of the linked article to learn more about it.
    – Hans Passant
    Nov 10 at 21:56










1




1




It would be better if Microsoft did not document these XxxxClass types. But they are a bit too obvious in a c# or vb.net project, so they kinda have to. They are "fake" classes, auto-generated by the type library importer. A COM coclass does not expose its implementation at all, it only lists what interfaces it implements. One is special, the default interface, Xxxx. The fake class merges the members of all the interfaces. A consequence of auto-generating it is that the fake class looks different in different VS versions. And that the docs can't keep up.
– Hans Passant
Nov 10 at 13:28




It would be better if Microsoft did not document these XxxxClass types. But they are a bit too obvious in a c# or vb.net project, so they kinda have to. They are "fake" classes, auto-generated by the type library importer. A COM coclass does not expose its implementation at all, it only lists what interfaces it implements. One is special, the default interface, Xxxx. The fake class merges the members of all the interfaces. A consequence of auto-generating it is that the fake class looks different in different VS versions. And that the docs can't keep up.
– Hans Passant
Nov 10 at 13:28












Thanks so much! What do you mean by XxxxClass type?
– FakeSaint
Nov 10 at 19:55




Thanks so much! What do you mean by XxxxClass type?
– FakeSaint
Nov 10 at 19:55




1




1




Xxxx == Solution in your question. It is the default interface, goes back to 2002. The actual class that implements it is written in C++, not visible at all. Today it also implements the Solution2, Solution3 and Solution4 interfaces. New features getting added over the years.
– Hans Passant
Nov 10 at 20:50




Xxxx == Solution in your question. It is the default interface, goes back to 2002. The actual class that implements it is written in C++, not visible at all. Today it also implements the Solution2, Solution3 and Solution4 interfaces. New features getting added over the years.
– Hans Passant
Nov 10 at 20:50












Hmm thank you lots to think about. You could move this to answer if you like :)
– FakeSaint
Nov 10 at 21:28




Hmm thank you lots to think about. You could move this to answer if you like :)
– FakeSaint
Nov 10 at 21:28




1




1




Just more of the way COM is special. They made the syntax look familiar to C# programmers. What really happens is that the CLR calls IUnknown.QueryInterface(). The actual C++ class object you created, more up to date than the SolutionClass wrapper you are looking at, knows about it so is happy to return the interface pointer. This interface-based programming paradigm is core to the way Microsoft writes its code. Follow the links at the bottom of the linked article to learn more about it.
– Hans Passant
Nov 10 at 21:56






Just more of the way COM is special. They made the syntax look familiar to C# programmers. What really happens is that the CLR calls IUnknown.QueryInterface(). The actual C++ class object you created, more up to date than the SolutionClass wrapper you are looking at, knows about it so is happy to return the interface pointer. This interface-based programming paradigm is core to the way Microsoft writes its code. Follow the links at the bottom of the linked article to learn more about it.
– Hans Passant
Nov 10 at 21:56



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235910%2finterface-method-missing-from-base-class-com%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235910%2finterface-method-missing-from-base-class-com%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini