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.