{"id":102543,"date":"2019-06-05T07:00:00","date_gmt":"2019-06-05T14:00:00","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/oldnewthing\/?p=102543"},"modified":"2019-06-04T22:20:28","modified_gmt":"2019-06-05T05:20:28","slug":"20190605-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20190605-00\/?p=102543","title":{"rendered":"Why does my C++\/WinRT project get errors of the form &#8216;<CODE>winrt::<\/CODE><CODE>impl::<\/CODE><CODE>produce&lt;D, I&gt;<\/CODE>&#8216;: cannot instantiate abstract class, missing method <CODE>GetBindingConnector<\/CODE>"},"content":{"rendered":"<p>So your <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/cpp-and-winrt-apis\/\"> C++\/WinRT<\/a> project gets build failures of the form<\/p>\n<pre style=\"white-space: pre-wrap;\">base.h(8208): error C2259: 'winrt::<wbr \/>impl::<wbr \/>produce&lt;D, I&gt;': cannot instantiate abstract class\r\nwith\r\n[\r\n    D=winrt::<wbr \/>YourNamespace::<wbr \/>implementation::<wbr \/>YourClass,\r\n    I=winrt::<wbr \/>Windows::<wbr \/>UI::<wbr \/>Xaml::<wbr \/>Markup::<wbr \/>IComponentConnector2\r\n] (compiling source file YourClass.cpp)\r\nbase.h(8208): note: due to following members: (compiling source file YourClass.cpp)\r\nbase.h(8208): note: 'int32_t winrt::<wbr \/>impl::<wbr \/>abi&lt;winrt::<wbr \/>Windows::<wbr \/>UI::<wbr \/>Xaml::<wbr \/>Markup::<wbr \/>IComponentConnector2, void&gt;::<wbr \/>type::<wbr \/>GetBindingConnector(int32_t, void *, void **) noexcept': is abstract (compiling source file YourClass.cpp)\r\n<\/pre>\n<p>Normally, the <code>Get\u00adBinding\u00adConnector<\/code> function is defined in <code>YourClass.xaml.g.hpp<\/code>, but that header file isn&#8217;t being generated.<\/p>\n<p>What&#8217;s going on, and how do you fix it?<\/p>\n<p>The problem is that you forgot to include the header file<\/p>\n<pre>#include \"winrt\/Windows.UI.Xaml.Markup.h\"\r\n<\/pre>\n<p>Add that line to, say, your precompiled header file, and things should work again.<\/p>\n<p>You are likely to run into this problem when upgrading a project from C++\/WinRT 1.0 to C++\/WinRT 2.0. The C++\/WinRT 2.0 compiler is much better about reducing header file dependencies, which improves build times. If you forgot to include <code>winrt\/Windows.UI.Xaml.Markup.h<\/code> in a C++\/WinRT 1.0 project, you often got away with it, because some other C++\/WinRT 1.0 header file you included happened to include <code>winrt\/Windows.UI.Xaml.Markup.h<\/code> as a side effect. You were getting a free ride on the other header file.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The header file requirement was always present, but you often got away with omitting it. Not so much any more.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-102543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The header file requirement was always present, but you often got away with omitting it. Not so much any more.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/102543","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=102543"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/102543\/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=102543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=102543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=102543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}