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

时间:2011-08-19 18:58:51

标签: c# .net wpf visual-studio-2010

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

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

WPF Command Line

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

使用VS 2010 .net 4.0

enter image description here

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: 

3 个答案:

答案 0 :(得分:1)

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

app.xaml properties

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

答案 1 :(得分:0)

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

在我的案例中Menu -> Build -> Clean Solution项目运行后没有错误。

答案 2 :(得分:0)

将Windows 10显示语言从英语更改为德语(该应用程序最初是在德语系统上开发的)已为我修复。

相关问题