【问题标题】:IOException was unhandled - Cannot locate resource app.xamlIOException 未处理 - 找不到资源 app.xaml
【发布时间】:2011-08-19 18:58:50
【问题描述】:

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

我已经通过删除 App.xaml 中的 StartUpUri 实现了对应用程序的命令行支持:

WPF Command Line

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

使用 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: 

【问题讨论】:

  • 您能否详细说明“此错误”。
  • @BalamBalam - 我添加了屏幕截图和堆栈跟踪。
  • 我也一直收到错误消息。我厌倦了它。想知道您是否找到了解决方法...
  • 还没有,我现在只是进行重建以解决它。

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


【解决方案1】:

我以前在从 VS 2005 移植到 2008 时看到过该错误。在 2010 年从未见过。 由于某种原因,app.xaml 的构建设置丢失了。因此您可以检查 app.xaml 的属性。正确的设置如附图所示。

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

【讨论】:

    【解决方案2】:

    我的情况与问题中指定的情况相同(VS2010)。
    昨天,项目运行没有问题。今天,没有修改代码,项目报错。

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-03-23
        • 1970-01-01
        • 1970-01-01
        • 2019-04-07
        • 1970-01-01
        • 1970-01-01
        • 2013-08-10
        相关资源
        最近更新 更多