3

Windows の起動時に起動する 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()

問題は何ですか、以前にこの問題に直面した人はいますか???

4

2 に答える 2

3

デバッグ情報やコードを追加せずに明確に答えることは不可能ですが、CLRの問題のように聞こえます。たとえば、CLRランタイムが完全に初期化される前にアプリケーションが実行されている場合、ここで発生しているような例外が発生する可能性があります。WPFは主にマネージコードであるため、これは明確な可能性だと思います。

スタートアップエントリをHKLMからHKCUに移動することをお勧めします。このように、Windowsの起動時ではなく、ユーザーがログオンしたときにロードする必要があります。つまり、それまでにCLRが初期化されます。

それでも問題が解決しない場合は、ThreadAbortExceptionsでtry/catchを実行することをお勧めします。WPFが処理をサポートしているかどうかを頭の中で思い出せませんが、サポートしている場合は、実行をブートスタックのユーザーログイン部分に移動しても修正されない場合は、それが最善の策だと思います。

有用な情報源:

http://msdn.microsoft.com/en-us/library/system.threading.threadabortexception.aspx

新しい管理対象アプリケーションがロードされるたびに、CLRがロードおよび初期化されますか?

于 2011-12-12T22:08:17.540 に答える
0

詳細を確認していただけますか

  • 内部例外はありますか?
  • システムイベントログにエントリはありますか。
  • パフォーマンスカウンターを設定し、clrの障害(perfmon.exe)がないか確認してください
  • Hope you know about the events in Application class such as DispatcherUnhandledException .Please subscribe to those. That will help to catch exception which are missed in try{}catch{}
于 2011-12-13T11:17:41.647 に答える