{"id":104711,"date":"2021-01-13T07:00:00","date_gmt":"2021-01-13T15:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=104711"},"modified":"2021-01-13T09:06:56","modified_gmt":"2021-01-13T17:06:56","slug":"20210113-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20210113-00\/?p=104711","title":{"rendered":"The misleading MIDL error message: MIDL5023: The arguments to the parameterized interface are not valid"},"content":{"rendered":"<p>Suppose you&#8217;re writing an IDL file for the Windows Runtime. You have a method that returns a vector view of strings, but for some reason the compiler tells you that &#8220;The arguments to the parameterized interface are not valid.&#8221;<\/p>\n<pre>runtimeclass Widget\r\n{\r\n  Windows.Foudation.Collections.IVectorView&lt;String&gt; GetNames();\r\n}\r\n<\/pre>\n<p>The argument to the parameterized interface is <code>String<\/code>, and that&#8217;s certainly a valid argument for <code>IVector\u00adView<\/code>, isn&#8217;t it?<\/p>\n<p>Yes, it&#8217;s a perfectly fine argument for <code>IVector\u00adView<\/code>.<\/p>\n<p>But what you have there isn&#8217;t the <code>IVector\u00adView<\/code> you think you have.<\/p>\n<pre>  Windows.<u>Foudation<\/u>.Collections.IVectorView&lt;String&gt; GetNames();\r\n<\/pre>\n<p>You misspelled <code>Foundation<\/code>.<\/p>\n<p>The compiler is technically correct: <code>String<\/code> is not a valid argument for the parameterized interface <code>Windows.<\/code><code>Foudation.<\/code><code>Collections.<\/code><code>IVectorView<\/code>. But that&#8217;s because <i>there are no possible valid arguments<\/i> for the parameterized interface <code>Windows.<\/code><code>Foudation.<\/code><code>Collections.<\/code><code>IVectorView<\/code>, because <code>Windows.<\/code><code>Foudation.<\/code><code>Collections.<\/code><code>IVectorView<\/code> is not a legal parameterized interface!<\/p>\n<p>The order in which the compiler checks for validity happens to result in a misleading error message, making you believe that the error is in the argument, when in fact the error is in the interface.<\/p>\n<p><b>Bonus chatter<\/b>: You can avoid some of the risk of typos by taking advantage of <a title=\"The Windows Runtime IDL compiler lets you abbreviate some interface names\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200316-00\/?p=103564\"> the shorthand notation<\/a> that lets you omit <code>Windows.<\/code><code>Foundation.<\/code><code>Collections<\/code>:<\/p>\n<pre>runtimeclass Widget\r\n{\r\n  IVectorView&lt;String&gt; GetNames();\r\n}\r\n<\/pre>\n<p>Of course, you can still get the misleading error message if you typo <code>IVectorView<\/code> as, say, <code>IVetorView<\/code>. So the problem is still there. The shorthand just makes it a little bit less likely.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>They aren&#8217;t valid, but then again, nothing would have been.<\/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-104711","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>They aren&#8217;t valid, but then again, nothing would have been.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104711","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=104711"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104711\/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=104711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=104711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=104711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}