wpf Application.Current.Shutdown(); 在未引用的程序集中定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15434636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Application.Current.Shutdown(); is defined in an assembly not referenced
提问by Joetjah
I'm getting the error:
我收到错误:
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'.
错误 1 在未引用的程序集中定义了类型“System.Windows.Markup.IQueryAmbient”。您必须添加对程序集“System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。
When doing the following:
执行以下操作时:
public void ExitApplication()
{
Application.Current.Shutdown();
}
The project is targeted to .NET 4.0, my Visual Studio is 2010, I tried adding
该项目针对.NET 4.0,我的Visual Studio是2010,我尝试添加
using System.Windows.Markup;with no succes, and
using System.Windows.Markup;没有成功,并且
using System.Xaml;where Xaml doesn't exist in namespace System.
using System.Xaml;Xaml 在命名空间系统中不存在的地方。
What should I do to fix this?
我该怎么做才能解决这个问题?
回答by DHN
回答by Antonio Bakula
Add System.Xaml.dll to project references.
将 System.Xaml.dll 添加到项目引用。
回答by TimVK
You need to add a referenceto System.Xamlin your main application project. Using System.Xamlis not needed to be in your code.
您需要在主应用程序项目中添加一个referenceto System.Xaml。Using System.Xaml不需要出现在您的代码中。

