{"id":37043,"date":"2004-12-13T07:00:00","date_gmt":"2004-12-13T15:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/12\/13\/why-do-i-get-e_nointerface-when-creating-an-object-that-supports-that-interface\/"},"modified":"2025-04-05T06:37:01","modified_gmt":"2025-04-05T13:37:01","slug":"20041213-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20041213-00\/?p=37043","title":{"rendered":"Why do I get E_NOINTERFACE when creating an object that supports that interface?"},"content":{"rendered":"<p>I&#8217;ve seen a few questions from people who call <a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/api\/combaseapi\/nf-combaseapi-cocreateinstance\"> the <code>CoCreateInstance<\/code> function<\/a>, asking for an interface that they know the object supports, yet receiving error <code>E_NOINTERFACE<\/code>. What&#8217;s going on?<\/p>\n<p>You&#8217;re seeing <a title=\"Why do I get a QueryInterface(IID_IMarshal) and then nothing?\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040220-00\/?p=40533\"> the same problem as the missing IMarshal<\/a>, just from the other side.<\/p>\n<p>If your threading model is incompatible with the threading model of the object you&#8217;re creating, then COM marshalling kicks in. And if the marshalling stuff isn&#8217;t there, the error that comes out is <code>E_NOINTERFACE<\/code>, because the marshalling interface is missing.<\/p>\n<p>A common source of this is attempting to use COM objects provided by the shell from a multi-threaded apartment. Remember that shell COM objects are, for the most part, apartment-threaded, not free-threaded. If you want to use shell objects, you should do so from single-threaded apartments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s the other half of the missing IMarshal.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-37043","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>It&#8217;s the other half of the missing IMarshal.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=37043"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37043\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=37043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=37043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=37043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}