{"id":2531,"date":"2007-09-04T19:39:21","date_gmt":"2007-09-04T19:39:21","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/wpf-windowsformshost-control-error\/"},"modified":"2016-07-28T10:49:09","modified_gmt":"2016-07-28T10:49:09","slug":"wpf-windowsformshost-control-error","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/wpf-windowsformshost-control-error\/","title":{"rendered":"WPF: WindowsFormsHost Control Error"},"content":{"rendered":"<p>I had the code base for&#160;my first WPF application ready to go, so I compiled a release version of software and tried to run it from the .exe instead of directly from Visual Studio.&#160; I was promptly greeted with the following error:<\/p>\n<p><strong>The tag &#8216;WindowsFormsHost&#8217; does not exist in XML namespace &#8216;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&#8217;.<\/strong><\/p>\n<p>It ran flawlessly from the Visual Studio .NET debugger,&#160;which I found a bit odd.&#160; I tracked the issue back to the following problem.&#160; When I originally referenced the WindowsFormsIntegration.DLL from my project, the &#8220;Copy Local&#8221; option was set to false.&#160; When I went back in and set that value to True, the application promptly broke when it ran in the debugger.&#160; I don&#8217;t mind when things break as long as they break consistently, so this was a step in the right direction.&#160; I had found a few helpful forum entries informing me that you have to specify the xml namespace for the WindowsFormsIntegration assembly.&#160; So I added the following xmlns entry:<\/p>\n<p><strong>xmlns:wfi=&#8221;clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration&#8221;<\/strong><\/p>\n<p>And changed my WindowsFormsIntegration tag from<\/p>\n<p><strong>&lt;WindowsFormsHost&gt;<br \/>&#160;&#160;&#160; &#8230;<br \/>&lt;\/WindowsFormsHost&gt;<\/strong><\/p>\n<p>to<\/p>\n<p><strong>&lt;wfi:WindowsFormsHost&gt;<br \/>&#160;&#160;&#160; &#8230;<br \/>&lt;\/wfi:WindowsFormsHost&gt;<\/strong><\/p>\n<p>and it started working just fine.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had the code base for&#160;my first WPF application ready to go, so I compiled a release version of software and tried to run it from the .exe instead of directly from Visual Studio.&#160; I was promptly greeted with the following error: The tag &#8216;WindowsFormsHost&#8217; does not exist in XML namespace &#8216;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&#8217;. It ran flawlessly&#8230;&hellip;<\/p>\n","protected":false},"author":46738,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-2531","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46738"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=2531"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2531\/revisions"}],"predecessor-version":[{"id":41550,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2531\/revisions\/41550"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=2531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=2531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=2531"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=2531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}