IOException未处理 – 无法找到资源app.xaml

在我的一个WPF项目中,当我打开解决方案并在调试时启动它时出现此错误。 如果我重新构建解决方案并再次启动它,则错误消失。

我已经使用以下方法删除了App.xaml中的StartUpUri,为应用程序实现了命令行支持:

WPF命令行

我如何摆脱这个恼人的错误?

使用VS 2010 .net 4.0

在此处输入图像描述

System.IO.IOException was unhandled Message=Cannot locate resource 'app.xaml'. Source=PresentationFramework StackTrace: at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access) at System.IO.Packaging.PackagePart.GetStream(FileMode mode, FileAccess access) at System.IO.Packaging.PackagePart.GetStream() at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) at ESPS3.ServerSchemaUtility.App.InitializeComponent() in e:\ESP3.0\InternalTools\ServerSchemaUtility\ServerSchemaUtility\App.xaml:line 1 at ESPS3.ServerSchemaUtility.App.Main() in E:\ESP3.0\InternalTools\ServerSchemaUtility\ServerSchemaUtility\obj\x86\Debug\App.g.cs:line 0 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: 

从VS 2005移植到2008年之前,我已经看到过这个错误。2010年从未见过。出于某种原因,app.xaml的构建设置丢失了。 所以你可以查看app.xaml的属性。 正确的设置显示在附件中。

app.xaml属性

另一方面,如果你正在使用MVVC,它可能是一个不同的原因,如下所述: http ://social.msdn.microsoft.com/Forums/en-US/wpf/thread/39d7a4dd-9034-4ae8 -843c-ccd4940ba51c /

我的问题与指定的情况相同(VS2010)。
昨天,项目没有问题。 今天,在没有更改代码的情况下,项目报告错误。

在我的情况下, Menu -> Build -> Clean Solution项目运行没有错误。