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\Debu开发者_JAVA技巧g\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.
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
Was this project migrated from .NET 3.5 to NET 4.0 ? If yes, the interface now resides in System.Xaml and you need to reference it.
In my case "System.Xaml" was added to the project automatically but giving the same type of error:
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,.... .' Consider adding a reference to that assembly.
I've solved the problem by, just deleting the "System.Xaml" from References and again adding "System.Xaml, Version=4.0.0.0" from Framework.
精彩评论