System.Windows.Markup.IQueryAmbient 在未被应用的程序集中定义

按照《WIndows Presentation Foundation》中介绍建立的WPF程序,可以在VS2008中创建控制台应用程序所得。创建之后将程序集输出类型改为:Windows应用程序。然后引用几个程序集就可以:system.dll,presentationframework.dll,windowsbase.dll和presentationcore.dll就可以正常运行。

但是在VS2010中会出现编译错误:“System.Windows.Markup.IQueryAmbient' is defined in an assembly that is notreferenced. You must add a reference to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”。其原因就是原有的System.windows.markup命名空间当中的类和接口有相当一部分从过去的Windowsbase.dll移植到了System.xaml.dll当中。因此需要添加对System.xaml.dll的引用。

原文地址:https://www.cnblogs.com/xpvincent/p/3831715.html