除开使用WPF的ShowDialog的表格时,表格、WPF、ShowDialog

2023-09-04 22:54:04 作者:小季风

我有一个WPF应用程序,尝试使用打开表单时,的ShowDialog(),我得到这个奇怪的例外,下面一台机器上。 任何想法是什么问题呢?

  

异常消息=操作已中止   (从HRESULT异常:0x80004004   (E_ABORT))异常堆栈跟踪=   在   System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(的Int32   错误code,IntPtr的errorInfo中)在   System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(的Int32   错误code,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的&放大器;字体样式,   粗细和放大器; fontWeight设置,FontStretch和放大器;   fontStretch)在   System.Windows.Media.FontFamily.LookupFontFamilyAndFace(CanonicalFontFamilyReference   canonicalFamilyReference,fontstyle的&放大器;   样式,粗细和放大器;重量,   FontStretch和放大器;拉伸)在   System.Windows.Media.FontFamily.FindFirstFontFamilyAndFace(fontstyle的&放大器;   样式,粗细和放大器;重量,   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 linelength个,双   paragraphWidth,   TextParagraphProperties   paragraphProperties,TextLineBreak   previousLineBreak,TextRunCache   textRunCache)在   MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource   textSource,的Int32 firstCharIndex,   双paragraphWidth,   TextParagraphProperties   paragraphProperties,TextLineBreak   previousLineBreak,TextRunCache   textRunCache)在   System.Windows.Controls.TextBoxLine.Format(的Int32   DCP,双formatWidth,双   paragraphWidth,LineProperties   lineProperties,TextRunCache   textRunCache,格式化的TextFormatter)   在   System.Windows.Controls.TextBoxView.FullMeasureTick(双人间   constraintWidth,LineProperties   lineProperties)在   System.Windows.Controls.TextBoxView.MeasureOverride(大小   约束)在   System.Windows.FrameworkElement.MeasureCore(大小   availableSize)在   System.Windows.UIElement.Measure(大小   availableSize)在   MS.Internal.Helper.MeasureElementWithSingleChild(的UIElement   元素,大小约束)的   System.Windows.Controls.ScrollContent presenter.MeasureOverride(尺寸   约束)在   System.Windows.FrameworkElement.MeasureCore(大小   availableSize)在   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.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(大小   availableSize)在   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.FrameworkElement.MeasureCore(大小   availableSize)在   System.Windows.UIElement.Measure(大小   availableSize)在   MS.Internal.Helper.MeasureElementWithSingleChild(的UIElement   元素,大小约束)的   System.Windows.Controls.Content presenter.MeasureOverride(尺寸   约束)在   System.Windows.FrameworkElement.MeasureCore(大小   availableSize)在   System.Windows.UIElement.Measure(大小   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.UIElement.Measure(大小   availableSize)在   System.Windows.Window.MeasureOverrideHelper(大小   约束)在   System.Windows.Window.MeasureOverride(大小   availableSize)在   System.Windows.FrameworkElement.MeasureCore(大小   availableSize)在   System.Windows.UIElement.Measure(大小   availableSize)在   System.Windows.Interop.HwndSource.SetLayoutSize()   在   System.Windows.Interop.HwndSource.set_RootVisu​​alInternal(可视化   值)在   System.Windows.Interop.HwndSource.set_RootVisu​​al(可视化   值)在   System.Windows.Window.SetRootVisu​​al()   在   System.Windows.Window.SetRootVisu​​alA​​ndUpdateSTC()   在   System.Windows.Window.SetupInitialState(双人间   requestedTop,双requestedLeft,   双requestedWidth,双   requestedHeight)在   System.Windows.Window.CreateSourceWindow(布尔   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.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(代表   回调,对象的args,的Int32 numArgs)   在   MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象   源,委托方法,对象指定参数时,   INT32 numArgs,代表catchHandler)

解决方案

我已经经历了同样的错误,问题是与Windows presentation基础字​​体缓存服务。它的缓存文件被莫名其妙地损坏。按照此MS知识库文章中的说明, http://support.microsoft.com/kb/937135 ,我能得到这个问题消失。

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

在我发现一篇文章,我刚刚停止并禁用该服务,我的WPF应用程序启动权了。我怀疑禁用它会显示WPF应用程序(这是够慢的话)下降导致缓慢,但有几台机器在外地有这样的伊苏斯之后,我禁用它,因为有没有问题。

如何在Excel表格中将sheet1的数据引用到sheet2中用来计算

I have a WPF application, when trying to open a form using ShowDialog(), I get this weird exception below on one machine. Any idea what the problem might be?

Exception Message = Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) Exception stack trace = at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo) at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr) at MS.Internal.Text.TextInterface.FontCollection.FindFamilyName(String familyName, UInt32& index) at MS.Internal.FontCache.FamilyCollection.LookupFamily(String familyName, FontStyle& fontStyle, FontWeight& fontWeight, FontStretch& fontStretch) at System.Windows.Media.FontFamily.LookupFontFamilyAndFace(CanonicalFontFamilyReference canonicalFamilyReference, FontStyle& style, FontWeight& weight, FontStretch& stretch) at System.Windows.Media.FontFamily.FindFirstFontFamilyAndFace(FontStyle& style, FontWeight& weight, FontStretch& stretch) at System.Windows.Media.Typeface.ConstructCachedTypeface() at System.Windows.Media.Typeface.get_CachedTypeface() at MS.Internal.TextFormatting.SimpleTextLine..ctor(FormatSettings settings, Int32 cpFirst, Int32 paragraphWidth, ArrayList runs, Int32& trailing, Int32& trailingSpaceWidth) at MS.Internal.TextFormatting.SimpleTextLine.Create(FormatSettings settings, Int32 cpFirst, Int32 paragraphWidth) at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache) at MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache) at System.Windows.Controls.TextBoxLine.Format(Int32 dcp, Double formatWidth, Double paragraphWidth, LineProperties lineProperties, TextRunCache textRunCache, TextFormatter formatter) at System.Windows.Controls.TextBoxView.FullMeasureTick(Double constraintWidth, LineProperties lineProperties) at System.Windows.Controls.TextBoxView.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV) at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV) at System.Windows.Controls.Grid.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Border.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Control.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV) at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV) at System.Windows.Controls.Grid.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Controls.Border.MeasureOverride(Size constraint) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Window.MeasureOverrideHelper(Size constraint) at System.Windows.Window.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize) at System.Windows.UIElement.Measure(Size availableSize) at System.Windows.Interop.HwndSource.SetLayoutSize() at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value) at System.Windows.Interop.HwndSource.set_RootVisual(Visual value) at System.Windows.Window.SetRootVisual() at System.Windows.Window.SetRootVisualAndUpdateSTC() at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight) at System.Windows.Window.CreateSourceWindow(Boolean duringShow) at System.Windows.Window.CreateSourceWindowDuringShow() at System.Windows.Window.SafeCreateWindowDuringShow() at System.Windows.Window.ShowHelper(Object booleanBox) at System.Windows.Window.Show() at System.Windows.Window.ShowDialog() at Alberstein.UI.Views.MainView.menuWorkOnline_Click(Object sender, RoutedEventArgs e) at Alberstein.UI.Views.MainView.checkSyncstatus() at Alberstein.UI.App.OnStartup(Object sender, StartupEventArgs e) at System.Windows.Application.OnStartup(StartupEventArgs e) at System.Windows.Application.<.ctor>b__1(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

解决方案

I've experienced this same error, and the problem is with the Windows Presentation Foundation Font Cache Service. Its cache file is somehow corrupted. By following the instructions in this MS KB article, http://support.microsoft.com/kb/937135, I was able to get the problem to go away.

This applies to both the 3.0.0.0 and 4.0.0.0 versions of the Cache.

Before I found that article, I had just stopped and disabled the service, and my WPF application started right up. I suspect disabling it will cause a slow down in displaying WPF applications (which is slow enough already), but after having several machines in the field have this issus, I disabled it and have had no problems since.