Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
应用程序重新启动时System.Windows.Markup.WpfXamlLoader.Load中的System.Threading.ThreadAbortException_Wpf_Xaml_Threadabortexception - Fatal编程技术网

应用程序重新启动时System.Windows.Markup.WpfXamlLoader.Load中的System.Threading.ThreadAbortException

应用程序重新启动时System.Windows.Markup.WpfXamlLoader.Load中的System.Threading.ThreadAbortException,wpf,xaml,threadabortexception,Wpf,Xaml,Threadabortexception,我已经创建了一个在windows start上启动的WPF应用程序。应用程序检查系统上的文件列表,如果缺少任何文件,则弹出文件路径 我面临的问题是,当我在应用程序运行时重新启动系统时,在重新启动时,我的应用程序会崩溃并抛出system.Threading.ThreadAbortException。下面是我在事件日志中获得的堆栈跟踪 Application: FileValidator.exe Framework Version: v4.0.30319 Description: The proce

我已经创建了一个在windows start上启动的WPF应用程序。应用程序检查系统上的文件列表,如果缺少任何文件,则弹出文件路径

我面临的问题是,当我在应用程序运行时重新启动系统时,在重新启动时,我的应用程序会崩溃并抛出system.Threading.ThreadAbortException。下面是我在事件日志中获得的堆栈跟踪

Application: FileValidator.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Threading.ThreadAbortException
Stack:
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
   at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
   at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
   at System.Windows.Application.LoadComponent(System.Uri, Boolean)
   at System.Windows.Application.DoStartup()
   at System.Windows.Application.<.ctor>b__1(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.runTryCode(System.Object)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at System.Windows.Application.Run(System.Windows.Window)
   at System.Windows.Application.Run()
   at FileValidator.App.Main()
应用程序:FileValidator.exe
框架版本:v4.0.30319
描述:由于未处理的异常,进程已终止。
异常信息:System.Threading.ThreadAbortException
堆栈:
在System.Windows.Markup.wpfxamloader.Load(System.Xaml.XamlReader、System.Xaml.IXamlObjectWriterFactory、Boolean、System.Object、System.Xaml.XamlObjectWriterSettings、System.Uri)
位于System.Windows.Markup.wpfxamloader.LoadBaml(System.Xaml.XamlReader,Boolean,System.Object,System.Xaml.Permissions.XamlAccessLevel,System.Uri)
位于System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream、System.Windows.Markup.ParserContext、System.Object、Boolean)
位于System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream、System.Windows.Markup.ParserContext)
位于System.Windows.Application.LoadComponent(System.Uri,布尔值)
在System.Windows.Application.DoStartup()中
在System.Windows.Application.b__1(System.Object)中
位于System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate、System.Object、Int32)
位于MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object、System.Delegate、System.Object、Int32、System.Delegate)
在System.Windows.Threading.DispatcherOperation.InvokeImpl()中
位于System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
位于System.Threading.ExecutionContext.runTryCode(System.Object)
在System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuarantedCleanup(TryCode,CleanupCode,System.Object)中
位于System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext、System.Threading.ContextCallback、System.Object)
在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object,布尔值)
在System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Threading.ContextCallback,System.Object)上运行
在System.Windows.Threading.DispatcherOperation.Invoke()中
在System.Windows.Threading.Dispatcher.ProcessQueue()中
位于System.Windows.Threading.Dispatcher.WndProcHook(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef)
位于MS.Win32.hwndwapper.WndProc(IntPtr、Int32、IntPtr、IntPtr、Boolean ByRef)
位于MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
位于System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate、System.Object、Int32)
位于MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object、System.Delegate、System.Object、Int32、System.Delegate)
位于System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority,System.TimeSpan,System.Delegate,System.Object,Int32)
在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr,Int32,IntPtr,IntPtr)
位于MS.Win32.unsafentivemethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
位于System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
位于System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
在System.Windows.Threading.Dispatcher.Run()中
位于System.Windows.Application.RunDispatcher(System.Object)
位于System.Windows.Application.RunInternal(System.Windows.Window)
在System.Windows.Application.Run(System.Windows.Window)中
在System.Windows.Application.Run()处
在FileValidator.App.Main()处

问题是什么,以前有人遇到过这个问题吗?

如果没有更多的调试信息或代码可以查看,就不可能给出明确的答案,但这听起来像是CLR的问题。例如,如果您的应用程序是在CLR运行时完全初始化之前执行的,那么您可能会遇到一个异常,就像您在这里看到的一样。由于WPF主要是托管代码,我认为这是一种明显的可能性

我建议您将启动条目从HKLM移至HKCU。这样,它应该在用户登录时加载,而不是在Windows启动时加载,这意味着CLR将在那时初始化

如果这不起作用,MSDN建议您对ThreadAbortExceptions进行尝试/捕获。我记不清WPF是否支持处理,但如果支持,那么如果将执行移到启动堆栈的用户登录部分无法解决问题,那么这将是最好的选择

有用的资料来源:


你能再查一些细节吗

  • 是否有内部异常
  • 系统事件日志中是否有任何条目
  • 请设置性能计数器并检查clr的任何故障(perfmon.exe)
  • 希望您了解应用程序类中的事件,如DispatcherUnhandException。请订阅这些事件。这将有助于捕获在try{}catch{}中丢失的异常

windows重新启动时,应用程序是如何启动的?你能在调试器下运行它并逐步完成吗?@Russell:我正在创建注册表项以在windows start上启动应用程序。我可以在调试器下运行它,但由于问题只发生在机器重新启动后,所以在调试器下运行并没有意义。我的应用程序最初运行正常,问题仅在重新启动计算机后出现。您是否使用HKEY\U LOCAL\U machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Run键?是的,我正在使用此键您是否在使用文件系统监视?请发布代码以实时验证文件。是的,毫无疑问。WPF可以很好地处理异常。将异常写入日志文件或事件日志。@kris和xcalibur