.net – VisualStudio bug

netvisual studiowinformswpf

In VS 2010 created a new WinForm project. Added a new UserControl WPF.

2 compile-time errors appeared:

Error 1 The type
'System.Windows.Markup.IQueryAmbient'
is defined in an assembly that is not
referenced. You must add a reference
to assembly 'System.Xaml,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'. D:\Projets\WindowsFormsApplication2\UserControl1.xaml.cs 20 26 WindowsFormsApplication2

Error 2 The type name
'IComponentConnector' could not be
found in the namespace
'System.Windows.Markup'. This type has
been forwarded to assembly
'System.Xaml, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089'
Consider adding a reference to that
assembly. D:\Projets\WindowsFormsApplication2\obj\x86\Debug\UserControl1.g.cs 41 100 WindowsFormsApplication2

NB.

References like PresenationCore.dll, PresenationFramework.dll, WindowsBase.dll are added automatically when adding a new WPF UserControl to the WinForm project, so why not System.Xaml.dll too?

==============

Bug reported on Microsoft Connect.

Best Answer

it sounds like you just need a reference to System.Xaml.dll


Re whether this is a bug in VS; well, I suppose the templates could add that reference - I can reproduce it, so it may be worth logging on connect