简体   繁体   English

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

[英]IOException was unhandled - Cannot locate resource app.xaml

In one of my WPF projects I get this error when I open the solution and start it up when debugging it. 在我的一个WPF项目中,当我打开解决方案并在调试时启动它时出现此错误。 If I rebuild the solution and start it again, the error goes away. 如果我重新构建解决方案并再次启动它,则错误消失。

I have implemented command line support for application by removing the StartUpUri in App.xaml using this: 我已经使用以下方法删除了App.xaml中的StartUpUri,为应用程序实现了命令行支持:

WPF Command Line WPF命令行

How do I get rid of this annoying error? 我如何摆脱这个恼人的错误?

Using VS 2010 .net 4.0 使用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: 

I have seen that error before, when porting from VS 2005 to 2008. Never seen in 2010. For some reason, the build settings for app.xaml were lost. 从VS 2005移植到2008年之前,我已经看到过这个错误。2010年从未见过。出于某种原因,app.xaml的构建设置丢失了。 So you can check the the properties of app.xaml. 所以你可以查看app.xaml的属性。 The correct settings are shown in the image attached. 正确的设置显示在附加的图像中。

app.xaml属性

On the other hand, if you are working with MVVC, it can be a different cause, like explained here: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/39d7a4dd-9034-4ae8-843c-ccd4940ba51c/ 另一方面,如果你正在使用MVVC,它可能是一个不同的原因,如下所述: http ://social.msdn.microsoft.com/Forums/en-US/wpf/thread/39d7a4dd-9034-4ae8 -843c-ccd4940ba51c /

I have the same situation as specified in question (VS2010). 我有相同的情况(VS2010)。
Yesterday, project worked without problems. 昨天,项目没有问题。 Today, with no changes to the code, project reported error. 今天,在没有更改代码的情况下,项目报告错误。

In my case after Menu -> Build -> Clean Solution project run without error. 在我的情况下, Menu -> Build -> Clean Solution项目运行没有错误。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM