Dot-Net

視覺工作室錯誤?

  • December 8, 2010

在 VS 2010 中創建了一個新WinForm項目。添加了新的使用者控制項 WPF。

出現2個編譯時錯誤:

錯誤 1 類型“System.Windows.Markup.IQueryAmbient”在未引用的程序集中定義。您必須添加對程序集“System.Xaml,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”的引用。D:\Projets\WindowsFormsApplication2\UserControl1.xaml.cs 20 26 WindowsFormsApplication2

錯誤 2 在命名空間“System.Windows.Markup”中找不到類型名稱“IComponentConnector”。此類型已轉發到程序集 ‘System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ 考慮添加對該程序集的引用。D:\Projets\WindowsFormsApplication2\obj\x86\Debug\UserControl1.g.cs 41 100 WindowsFormsApplication2

注意。

PresenationCore.dll向 WinForm 項目添加新的 WPF UserControl 時會自動添加、PresenationFramework.dll、等引用WindowsBase.dll,為什麼不這樣做System.Xaml.dll呢?

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

**在Microsoft Connect**上報告的錯誤。

聽起來你只需要參考System.Xaml.dll


Re這是否是VS中的一個錯誤;好吧,我想模板可以添加該引用-我可以複製它,因此值得登錄 connect

引用自:https://stackoverflow.com/questions/4387812