.net - VisualStudio错误?

标签 .net wpf visual-studio winforms

在VS 2010中创建了一个新的WinForm项目。添加了新的UserControl WPF。

出现2个编译时错误:

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



注意。

当向WinForm项目添加新的WPF用户控件时,会自动添加诸如PresenationCore.dllPresenationFramework.dllWindowsBase.dll之类的引用,那么为什么不也添加System.Xaml.dll呢?

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

已在 Microsoft Connect 上报告了错误。

最佳答案

听起来您只需要引用System.Xaml.dll
关于这是否是VS中的错误;好吧,我想模板可以添加该引用-我可以复制它,因此值得logging on connect

关于.net - VisualStudio错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4387812/

相关文章:

c# - 在 c# 中需要有关多播 udp 服务器发现的帮助

.net - 用于 Shell 扩展安装的 ClickOnce 替代方案

visual-studio - F# 项目不支持生成依赖图?

visual-studio - F# VS2019 Windows 窗体

.net - 以编程方式禁止注册表虚拟化

.net - 可以在 ASP.NET MVC 中的 ValidationAttribute 中访问 HttpContext 吗?

c# - 使用 Entity Framework 将数据绑定(bind)到 WPF 中的数据网格

wpf - WPF Modern UI 的 '#1' 中的 '/Content/LoremIpsum.xaml#1' 是什么意思?

wpf - 从另一个ViewModel引发MVVM属性的最佳方法是什么?

visual-studio - 如何在 Visual Studio 中导出/导入工具栏