IOException异常是未处理 - 找不到资源的App.xaml找不到、异常、未处理、资源

2023-09-05 01:27:17 作者:苦涩的巧克力

在我的WPF项目之一,当我打开解决方案和调试,当它启动它,我得到这个错误。如果我重新生成解决方案并重新启动,错误消失。

应用

我已经实现了命令行支持通过使用这App.xaml中取出的StartupUri:

WPF命令行

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

使用VS 2010 .NET 4.0

  System.IO.IOException是未处理
  消息=无法找到资源的App.xaml。
  来源= presentationFramework
  堆栈跟踪:
       在MS.Internal.AppModel.ResourcePart.GetStreamCore(的FileMode模式,FileAccess的访问)
       在System.IO.Packaging.PackagePart.GetStream(的FileMode模式,FileAccess的访问)
       在System.IO.Packaging.PackagePart.GetStream()
       在System.Windows.Application.LoadComponent(对象组件,乌里resourceLocator)
       在ESPS3.ServerSchemaUtility.App.InitializeComponent()在E:\ ESP3.0 \ InternalTools \ ServerSchemaUtility \ ServerSchemaUtility \ App.xaml中:1号线
       在ESPS3.ServerSchemaUtility.App.Main()在E:\ ESP3.0 \ InternalTools \ ServerSchemaUtility \ ServerSchemaUtility \ OBJ \ 86 \调试\ App.g.cs:行0
       在System.AppDomain._nExecuteAssembly(RuntimeAssembly组装,字串[] args)
       在System.AppDomain.ExecuteAssembly(字符串assemblyFile,证据assemblySecurity,字串[] args)
       在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)
       在System.Threading.ExecutionContext.Run(ExecutionContext中的ExecutionContext,ContextCallback回调,对象的状态,布尔ignoreSyncCtx)
       在System.Threading.ExecutionContext.Run(ExecutionContext中的ExecutionContext,ContextCallback回调,对象的状态)
       在System.Threading.ThreadHelper.ThreadStart()
  的InnerException:
 
ioexception属于什么异常 Java 检查异常和未检查异常

解决方案

我所看到的错误之前,从2005年VS至2008年从来没有见过在2010年移植时。 出于某种原因,App.xaml中构建设置丢失。所以,你可以检查的App.xaml的属性。正确的设置,显示连接的图片。

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

In one of my WPF projects I get this error when I open the solution and start it up when debugging it. 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:

WPF Command Line

How do I get rid of this annoying error?

Using 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. So you can check the the properties of app.xaml. The correct settings are shown in the image attached.

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/