Damon Armstrong

Caffeine Induced Tirades about .NET and Life
And don't forget to check out my latest Simple-Talk articles
Add to Technorati Favorites      Add to Google     

WPF: WindowsFormsHost Control Error

Published Tuesday, September 04, 2007 7:39 PM

I had the code base for 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.  I was promptly greeted with the following error:

The tag 'WindowsFormsHost' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

It ran flawlessly from the Visual Studio .NET debugger, which I found a bit odd.  I tracked the issue back to the following problem.  When I originally referenced the WindowsFormsIntegration.DLL from my project, the "Copy Local" option was set to false.  When I went back in and set that value to True, the application promptly broke when it ran in the debugger.  I don't mind when things break as long as they break consistently, so this was a step in the right direction.  I had found a few helpful forum entries informing me that you have to specify the xml namespace for the WindowsFormsIntegration assembly.  So I added the following xmlns entry:

xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"

And changed my WindowsFormsIntegration tag from

<WindowsFormsHost>
    ...
</WindowsFormsHost>

to

<wfi:WindowsFormsHost>
    ...
</wfi:WindowsFormsHost>

and it started working just fine.

by Damon

Comments

No Comments
You need to sign in to comment on this blog


















<September 2007>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Niklaus Wirth: Geek of the Week
 It is difficult to begin to estimate the huge extent of the contribution that Niklaus Wirth has made to... Read more...

Building an Exchange Server 2007 environment
 Of course, changing a 32,000 mailbox system, based in 40 Exchange Servers, to a centralised 25,000... Read more...

Manage Stress Before it Kills You
 The key to a long career in IT is in learning how to cope adaptively with stress. Matt Simmons, like... Read more...

Expecting the Worst
 Optimists are often disappointed Read more...

To Boldly Ask IT for Development Work
 Phil has always been mystified by the way that, in Science-Fiction films, the crew of space-ships are... Read more...