« Optimizing Vista performanceVBUG Conference 2007 drawing closer »

WPF targets in Windows Forms project

26/09/07

Permalink 06:26:31 pm
Categories: General

WPF targets in Windows Forms project

I might be the last person to find this out, I don't know - in that case, regard it as a note to self.

I was working with a Windows Forms project, using an ElementHost to embed a WPF control. I was trying to create a WPF UserControl and it just wasn't working, because Visual Studio didn't seem to build the control correctly. For instance, the InitializeComponent method call in the constructor of the UserControl resulted in an error message. I looked around for a while and was a bit confused about possible sources of the problem. Then I compared two project files and found out that the targets for WPF are simply not there when the project wasn't originally created to target WPF - kind of obvious once you know it, but then what isn't...

I edited the project file of the Windows Forms project to include this line:

<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />

And voilá, suddenly everything builds just fine. Duh.

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
Please complete the song title below. Hint: enter 'h', 'e', 'a', 'v', 'e', 'n'
antispam test

Enter your email address:

Search

Oliver
MVP logo
March 2010
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31