2011-02-16 99 views
4


我有一个WPF应用程序,当试图使用ShowDialog()打开窗体时,我在一台机器上看到下面这个奇怪的异常。
任何想法可能是什么问题?使用WPF的ShowDialog打开窗体时出现异常

异常消息=操作中止 (从HRESULT异常:0x80004004 (E_ABORT))。异常堆栈跟踪=
在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(的Int32 的errorCode,IntPtr的errorInfo中)在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(的Int32 的errorCode,IntPtr的errorInfo中)在 MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(的Int32 小时)在 MS.Internal.Text.TextInterface.FontCollection.FindFamilyName (字符串 familyName,UInt32的&指数)在 MS.Internal.FontCache.FamilyCollection.LookupFamily(字符串 familyName,FontStyle & fontStyle, fontWeight设置& fontWeight设置,FontStretch & fontStretch)在 System.Windows.Media.FontFamily.LookupFontFamilyAndFace(CanonicalFontFamilyReference canonicalFamilyReference,FontStyle & 风格,fontWeight设置&重量, FontStretch &峰)在 System.Windows.Media.FontFamily.FindFirstFontFamilyAndFace(FontStyle & 风格,fontWeight设置&重量, FontStretch &峰)在 System.Windows.Media.Typeface.ConstructCachedTypeface() 在 System.Windows.Media.Typeface.get_CachedTypeface() 在 MS.Internal.TextFormatting.SimpleTextLine。 .ctor(FormatSettings 设置,的Int32 cpFirst,的Int32 paragraphWidth,ArrayList中运行时,的Int32 & 拖尾,的Int32 & trailingSpaceWidth)
在 MS.Internal.TextFormatting.SimpleTextLine.Create(FormatSettings 设置,的Int32 cpFirst,的Int32 paragraphWidth)在 MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource,的Int32 firstCharIndex, 的Int32线路长度,双 paragraphWidth, TextParagraphProperties paragraphProperties,TextLineBreak previousLineBreak,TextRunCache textRunCache)在 MS.Internal.TextFormatting .TextFormatterImp.FormatLine(textSource textSource,的Int32 firstCharIndex, 双paragraphWidth, TextParagraphProperties paragraphProperties,TextLineBreak previousLineBreak,TextRunCache 文本RunCache)在 System.Windows.Controls.TextBoxLine.Format(的Int32 DCP,双formatWidth,双 paragraphWidth,LineProperties lineProperties,TextRunCache textRunCache,格式化的TextFormatter) 在 System.Windows.Controls.TextBoxView。FullMeasureTick在 System.Windows.FrameworkElement.MeasureCore(尺寸 availableSize)在 System.Windows.UIElement.Measure((双人间 constraintWidth,LineProperties lineProperties)在 System.Windows.Controls.TextBoxView.MeasureOverride(尺寸 约束)大小 availableSize)处 System.Windows.Controls.ScrollContentPresenter.MeasureOverride(大小 约束) MS.Internal.Helper.MeasureElementWithSingleChild(的UIElement 元件,尺寸约束)在 System.Windows.FrameworkElement.MeasureCore(大小 availableSize )在 System.Window s.UIElement.Measure(尺码 availableSize)在 System.Windows.Controls.Grid.MeasureCell(的Int32 细胞,布尔forceInfinityV)在 System.Windows.Controls.Grid.MeasureCellsGroup(的Int32 cellsHead,尺寸referenceSize,布尔 ignoreDesiredSizeU,布尔 forceInfinityV)处 System.Windows.FrameworkElement.MeasureCore(尺码 availableSize) System.Windows.Controls.Grid.MeasureOverride(尺码 约束)在 System.Windows.UIElement.Measure(尺码 availableSize)在 System.Windows.Controls.ScrollViewer.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(尺寸 availableSize)在 System.Windows.UIElement.Measure(尺寸 availableSize)在 System.Windows.Controls.Border.MeasureOverride(尺寸 约束)在 System.Windows。 FrameworkElement.MeasureCore(尺寸 availableSize)在 System.Windows.UIElement.Measure(尺寸 availableSize)在 System.Windows.Controls.Control.MeasureOverride(尺寸 约束)在 System.Windows.FrameworkElement.MeasureCore(尺寸 可用大小)在 System.Windows.UIElement.Measure(大小 availableSize)在 System.Windows.Controls.Grid.MeasureCell(在 的Int32 细胞,布尔forceInfinityV)在 System.Windows.Controls.Grid.MeasureCellsGroup(的Int32 cellsHead,尺寸referenceSize,布尔 ignoreDesiredSizeU,布尔 forceInfinityV) System.Windows.Controls.Grid.MeasureOverride(尺寸 约束)在 System.Windows.FrameworkElement.MeasureCore(尺寸 availableSize)在 System.Windows.UIElement.Measure(尺寸 availableSize)在 System.Windows.Controls。 StackPanel.MeasureOverride(大小 约束)在 System.Windows.Framewor kElement.MeasureCore(尺码 availableSize)在 System.Windows.UIElement.Measure(尺码 availableSize)在 MS.Internal.Helper.MeasureElementWithSingleChild(的UIElement 元件,尺寸约束)在 System.Windows.Controls.ContentPresenter.MeasureOverride (尺码 约束)处 System.Windows.UIElement.Measure(尺码 availableSize) System.Windows.FrameworkElement.MeasureCore(尺码 availableSize)在 System.Windows.Documents.AdornerDecorator.MeasureOverride(尺码 约束)在 System.Windows.FrameworkElement。的MeasureCore(尺寸 availableSize)在 System.Windows.UIElement.Measure(尺寸 availableSize)在 System.Windows.Controls.Border.MeasureOverride(尺寸 约束)在 System.Windows.FrameworkElement.MeasureCore(尺寸 availableSize)在处 System.Windows.Window.MeasureOverride(尺寸 availableSize) System.Windows.Window.MeasureOverrideHelper(尺寸 约束) System.Windows.UIElement.Measure(尺寸 availableSize)在 System.Windows.FrameworkElement。 MeasureCore(大小 可用大小)在 System.Windows。 UIElement.Measure(尺寸 availableSize)在 System.Windows.Interop.HwndSource.SetLayoutSize() 在 System.Windows.Interop.HwndSource.set_RootVisualInternal(视觉 值) System.Windows.Interop.HwndSource.set_RootVisual(视觉 值) System.Windows.Window.SetRootVisual() 在 System.Windows.Window.SetRootVisualAndUpdateSTC() 在 System.Windows.Window.SetupInitialState(双人间 requestedTop,双requestedLeft, 双requestedWidth,双 requestedHeight)at System.Windows.Window.Creat eSourceWindow(布尔 duringShow)在 System.Windows.Window.CreateSourceWindowDuringShow() 在 System.Windows.Window.SafeCreateWindowDuringShow() 在 System.Windows.Window.ShowHelper(对象 booleanBox)在 System.Windows。 Window.Show()在 System.Windows.Window.ShowDialog()
处 Alberstein.UI.Views.MainView.checkSyncstatus Alberstein.UI.Views.MainView.menuWorkOnline_Click(对象 发件人,RoutedEventArgs E)()在Alberstein.UI.App.OnStartup(Object sender,StartupEventArgs e)处的 System.Windows.Application.OnStartup(StartupEventArgs e)at System.Windows.Application。 < .ctor> b__1(对象 未使用的)在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(代表 回调,对象指定参数时,的Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象 源,代表方法,Object args, Int32 numArgs,Delegate catchHandler)

+5

这是你发布的一个可爱的堆栈跟踪。你读过了吗?特别是,正在寻找字体的那部分堆栈? `...在MS.Internal.Text.TextInterface.FontCollection.FindFamilyName(字符串familyName,UInt32&索引)...' – 2011-02-16 22:37:05

+2

@djacobson:闻起来像一个答案,你想别人重新发布它为你或会自己做? – 2011-02-16 23:03:27

回答

6

我遇到过同样的错误,问题出在Windows Presentation Foundation字体缓存服务上。其缓存文件以某种方式损坏。按照本MS KB文章 http://support.microsoft.com/kb/937135中的说明,我能够解决问题。

这适用于Cache的3.0.0.0和4.0.0.0版本。

在我发现那篇文章之前,我刚刚停止并禁用了该服务,并且我的WPF应用程序正常启动。我怀疑禁用它会导致显示WPF应用程序(已经足够慢),但有多台机器有这个问题后,我禁用它,并没有任何问题,因为后来减慢。