【问题标题】:Exception when opening a Form using WPF's ShowDialog使用 WPF 的 ShowDialog 打开表单时出现异常
【发布时间】:2011-06-28 17:11:36
【问题描述】:


我有一个 WPF 应用程序,当尝试使用 ShowDialog() 打开一个表单时,我在一台机器上得到了下面这个奇怪的异常。
知道可能是什么问题吗?

异常消息 = 操作中止 (来自 HRESULT 的异常:0x80004004 (E_ABORT)) 异常堆栈跟踪 =
在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 错误代码,IntPtr 错误信息)在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 错误代码,IntPtr 错误信息)在 MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 小时)在 MS.Internal.Text.TextInterface.FontCollection.FindFamilyName(字符串 familyName,UInt32& 索引)在 MS.Internal.FontCache.FamilyCollection.LookupFamily(字符串 家族名称、字体样式和字体样式、 字体重量&字体重量,字体拉伸& 字体拉伸)在 System.Windows.Media.FontFamily.LookupFontFamilyAndFace(CanonicalFontFamilyReference canonicalFamilyReference,字体样式& 样式,字体重量和重量, 字体拉伸和拉伸)在 System.Windows.Media.FontFamily.FindFirstFontFamilyAndFace(字体样式& 样式,字体重量和重量, 字体拉伸和拉伸)在 System.Windows.Media.Typeface.ConstructCachedTypeface() 在 System.Windows.Media.Typeface.get_CachedTypeface() 在 MS.Internal.TextFormatting.SimpleTextLine..ctor(FormatSettings 设置,Int32 cpFirst,Int32 段落宽度,ArrayList 运行,Int32& 尾随,Int32 和尾随空间宽度)
在 MS.Internal.TextFormatting.SimpleTextLine.Create(FormatSettings 设置,Int32 cpFirst,Int32 段落宽度)在 MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource,Int32 firstCharIndex, Int32 lineLength,双精度 段落宽度, 文本段落属性 段落属性,TextLineBreak 上一个换行符,TextRunCache textRunCache) 在 MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource,Int32 firstCharIndex, 双段宽度, 文本段落属性 段落属性,TextLineBreak 上一个换行符,TextRunCache textRunCache) 在 System.Windows.Controls.TextBoxLine.Format(Int32 dcp,双格式宽度,双精度 段落宽度,线条属性 线属性,TextRunCache textRunCache、TextFormatter 格式化程序) 在 System.Windows.Controls.TextBoxView.FullMeasureTick(双 约束宽度,线属性 线属性)在 System.Windows.Controls.TextBoxView.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 MS.Internal.Helper.MeasureElementWithSingleChild(UIElement 元素,尺寸约束)在 System.Windows.Controls.ScrollContentPresenter.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Controls.Grid.MeasureCell(Int32 单元格,布尔 forceInfinityV) 在 System.Windows.Controls.Grid.MeasureCellsGroup(Int32 单元格头,大小参考大小,布尔值 忽略DesiredSizeU,布尔值 forceInfinityV) 在 System.Windows.Controls.Grid.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Controls.ScrollViewer.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Controls.Border.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Controls.Control.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Controls.Grid.MeasureCell(Int32 单元格,布尔 forceInfinityV) 在 System.Windows.Controls.Grid.MeasureCellsGroup(Int32 单元格头,大小参考大小,布尔值 忽略DesiredSizeU,布尔值 forceInfinityV) 在 System.Windows.Controls.Grid.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Controls.StackPanel.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 MS.Internal.Helper.MeasureElementWithSingleChild(UIElement 元素,尺寸约束)在 System.Windows.Controls.ContentPresenter.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Documents.AdornerDecorator.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Controls.Border.MeasureOverride(大小 约束)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 System.Windows.Window.MeasureOverrideHelper(大小 约束)在 System.Windows.Window.MeasureOverride(大小 可用尺寸)在 System.Windows.FrameworkElement.MeasureCore(大小 可用尺寸)在 System.Windows.UIElement.Measure(大小 可用尺寸)在 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(双 请求顶部,双请求左侧, 双请求宽度,双倍 请求高度)在 System.Windows.Window.CreateSourceWindow(布尔值 期间)在 System.Windows.Window.CreateSourceWindowDuringShow() 在 System.Windows.Window.SafeCreateWindowDuringShow() 在 System.Windows.Window.ShowHelper(对象 布尔框)在 System.Windows.Window.Show() 在 System.Windows.Window.ShowDialog()
在 Alberstein.UI.Views.MainView.menuWorkOnline_Click(对象 发件人,RoutedEventArgs e) 在 Alberstein.UI.Views.MainView.checkSyncstatus() 在 Alberstein.UI.App.OnStartup(对象 发件人,StartupEventArgs e) 在 System.Windows.Application.OnStartup(StartupEventArgs 吃 System.Windows.Application.<.ctor>b__1(对象 未使用)在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托 回调,对象参数,Int32 numArgs) 在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象 源,委托方法,对象参数, Int32 numArgs,委托 catchHandler)

【问题讨论】:

  • 这是您发布的一个可爱的堆栈跟踪。你读过吗?特别是堆栈中正在寻找字体的部分? ...at MS.Internal.Text.TextInterface.FontCollection.FindFamilyName(String familyName, UInt32&amp; index)...
  • @djacobson:这听起来像是一个答案,你是想让别人为你重新发布还是自己做?

标签: .net wpf exception


【解决方案1】:

我也遇到过同样的错误,问题出在 Windows Presentation Foundation 字体缓存服务上。它的缓存文件以某种方式损坏。按照此 MS 知识库文章中的说明, http://support.microsoft.com/kb/937135,我解决了这个问题。

这适用于 3.0.0.0 和 4.0.0.0 版本的缓存。

在我找到那篇文章之前,我刚刚停止并禁用了该服务,并且我的 WPF 应用程序立即启动。我怀疑禁用它会导致显示 WPF 应用程序的速度变慢(这已经足够慢了),但是在现场有几台机器出现此问题后,我禁用了它,此后没有任何问题。

【讨论】:

  • 我们不得不禁用该服务。
猜你喜欢
  • 2019-03-04
  • 2017-11-18
  • 2013-08-30
  • 2021-12-21
  • 1970-01-01
  • 1970-01-01
  • 2012-12-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多