2010-11-18 52 views
0

这很奇怪。我有一个WPF应用程序,在DPI设置为96时可以在XP中正常工作,但在设置为120时会失败。我在两台独立的XP计算机上尝试了这种方法,结果相同。WPF在XP中以120 DPI失败,但没有96 DPI

在加载我的异常处理程序之前,初始化时发生错误。

你能给我一些关于如何调试的提示吗?这是事件日志条目之一。


Event Type: Error 
Event Source: .NET Runtime 
Event Category: None 
Event ID: 1026 
Date:  11/17/2010 
Time:  7:37:15 PM 
User:  N/A 
Computer: EXIDA-100A3799C 
Description: 
Application: exSILentia3.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.IO.FileFormatException 
Stack: 
    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 exSILentia3.Application.Main() 
+0

请以代码格式放置堆栈跟踪,以便我们可以轻松读取。 – Brad 2010-11-18 04:22:32

回答

2

您是否在任何一台机器上安装了Visual Studio?如果是这样,我建议在调试器中运行,并将其配置为在抛出异常时立即中断。从“调试”菜单中,打开“例外”对话框,展开Common Language Runtime Exceptions item,然后展开System.IO节以查找System.IO.FileFormatException项。确保检查第一列(投掷)。

我建议这样做的原因是,您显示的堆栈跟踪看起来像重新堆栈的堆栈,而不是原始异常。 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen方法抛出异常,该方法是检测未处理的异常的WPF消息循环的位。所以这在日志中显示的并不是什么有用的东西 - 您真正想知道的是在WPF捕获它之前最初抛出异常的位置。如果您要求调试器在引发该异常时立即停止,那么您将能够做到这一点。

这应该在这个问题上提供更多的信息。

如果这不是一个选项,您可以尝试附加一个处理程序到Dispatcher.UnhandledException事件或Application.DispatcherUnhandledException事件并添加一些自己的自定义日志记录代码。这可能会为您提供有关异常最初抛出的位置的更多信息。

在没有更详细的日志记录的情况下,发生在我身上的显而易见的事情是这样的(尽管它很长):你在任一系统上安装了任何不同寻常的字体吗?

+0

是的.. VS试图加载应用程序后立即崩溃,“没有源代码availabe”,就像错误的模糊。 – 2010-11-18 15:04:59

+0

好吧,但我的观点是我想查看堆栈跟踪的真正崩溃位置。不幸的是,默认情况下你不会得到这个结果 - 你最终得到了你发布的非特定堆栈跟踪。正如我上面所说的,整个想法是获得更有用的堆栈跟踪。这个例外与以前一样“模糊”,因为我期待看到相同的异常,但是如果我们能够看到*它从哪里抛出,那可能有助于解决问题。 – 2010-11-26 00:38:05

0

谢谢你的帮助。内部异常,是一个更多的帮助,它将它限制为一个位图文件错误。

我最终通过消除项目副本直到它工作,发现了它。这个问题在我的面前出现。当应用程序加载它加载一个主窗口。我很早就删除了此窗口的图标,但没有成功。直到后来我才回过头来,也删除了它装载的窗口中的图标(谢天谢地),我疯了。也许它在Windows资源中缓存了已删除图标的副本?

无论如何,我用我们的图标编辑器(Axialis IconWorkshop)来确保每个可能的图标格式都存在;没有成功。

我最终刚刚离开了无图标的窗口,并尝试在加载时加载图标,如果失败,我只是运行无图像。这并不完美,但在图标引起问题的有限情况下,我不希望它为此而崩溃。

在一个侧面说明,我也尝试加载一个较旧/较低的水库。版本的图标,如果第一个失败,并且在这种情况下工作。

我只是希望调试器能更好地帮助您找出问题所在。

0

你可能想看看你的图标的格式。我在使用高分辨率256图标的Vista前平台上的WPF应用程序出现问题。我的设计团队提供了一个图标,该图标使用PNG格式的256图标,旧平台无法加载。一旦该特定的图标被改为位图格式,一切都很好。