This is a migrated thread and some comments may be shown as answers.

RadGlyph FileFormatException

9 Answers 591 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 2
Joshua asked on 07 Dec 2018, 10:54 PM

I am getting a strange error on a customer PC with RadGlyph's.  They have a vanilla Win7 box with .Net 4.5.1, any idea what might cause this?  It works fine on my Win7 machine so I'm not sure where to look.

 

System.Windows.Markup.XamlParseException: Set property 'Telerik.Windows.Controls.RadGlyph.Glyph' threw an exception. ---> System.IO.FileFormatException: Input file or data stream does not conform to the expected file format specification.<br>   at MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr)<br>   at MS.Internal.Text.TextInterface.Font.CreateFontFace()<br>   at MS.Internal.Text.TextInterface.Font.AddFontFaceToCache()<br>   at MS.Internal.Text.TextInterface.Font.GetFontFace()<br>   at System.Windows.Media.GlyphTypeface..ctor(Font font)<br>   at MS.Internal.FontFace.PhysicalFontFamily.GetGlyphTypeface(FontStyle style, FontWeight weight, FontStretch stretch)<br>   at MS.Internal.FontFace.PhysicalFontFamily.MS.Internal.FontFace.IFontFamily.GetTypefaceMetrics(FontStyle style, FontWeight weight, FontStretch stretch)<br>   at System.Windows.Media.Typeface.ConstructCachedTypeface()<br>   at System.Windows.Media.Typeface.get_CachedTypeface()<br>   at System.Windows.Media.Typeface.CheckFastPathNominalGlyphs(CharacterBufferRange charBufferRange, Double emSize, Double scalingFactor, Double widthMax, Boolean keepAWord, Boolean numberSubstitution, CultureInfo cultureInfo, TextFormattingMode textFormattingMode, Boolean isSideways, Boolean breakOnTabs, Int32& stringLengthFit)<br>   at MS.Internal.TextFormatting.SimpleRun.CreateSimpleTextRun(CharacterBufferRange charBufferRange, TextRun textRun, TextFormatterImp formatter, Int32 widthLeft, Boolean emergencyWrap, Boolean breakOnTabs)<br>   at MS.Internal.TextFormatting.SimpleRun.Create(FormatSettings settings, CharacterBufferRange charString, TextRun textRun, Int32 cp, Int32 cpFirst, Int32 runLength, Int32 widthLeft, Int32 idealRunOffsetUnRounded)<br>   at MS.Internal.TextFormatting.SimpleTextLine.Create(FormatSettings settings, Int32 cpFirst, Int32 paragraphWidth)<br>   at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)<br>   at MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak)<br>   at System.Windows.Media.FormattedText.LineEnumerator.FormatLine(TextSource textSource, Int32 textSourcePosition, Double maxLineLength, TextParagraphProperties paraProps, TextLineBreak lineBreak)<br>   at System.Windows.Media.FormattedText.LineEnumerator.MoveNext()<br>   at System.Windows.Media.FormattedText.DrawAndCalculateMetrics(DrawingContext dc, Point drawingOffset, Boolean getBlackBoxMetrics)<br>   at System.Windows.Media.FormattedText.get_Metrics()<br>   at Telerik.Windows.Controls.RadGlyph.CalculateElementDesiredSize()<br>   at Telerik.Windows.Controls.RadGlyph.RemeasureElement(DependencyObject d, DependencyPropertyChangedEventArgs e)<br>   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)<br>   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)<br>   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)<br>   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)<br>   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)<br>   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)<br>   at System.Windows.Baml2006.WpfMemberInvoker.SetValue(Object instance, Object value)<br>   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)<br>   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)<br>   --- End of inner exception stack trace ---<br>   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)<br>   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)<br>   at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)<br>   at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)<br>   at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)<br>   at System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container)<br>   at System.Windows.FrameworkElement.ApplyTemplate()<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Controls.Control.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)<br>   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)<br>   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)<br>   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Controls.Border.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)<br>   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)<br>   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)<br>   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)<br>   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Controls.Border.MeasureOverride(Size constraint)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.Window.MeasureOverrideHelper(Size constraint)<br>   at System.Windows.Window.MeasureOverride(Size availableSize)<br>   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)<br>   at System.Windows.UIElement.Measure(Size availableSize)<br>   at System.Windows.ContextLayoutManager.UpdateLayout()<br>   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)<br>   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()<br>   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()<br>   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)<br>   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)<br>   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)<br>   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

9 Answers, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 2
answered on 07 Dec 2018, 10:56 PM
I saw the "TypeInitializationException" or "FileFormatException" error in a WPF application thread but they don't have any of those MS updates installed
0
Joshua
Top achievements
Rank 2
answered on 07 Dec 2018, 11:45 PM

More details:  I am able to replicate the problem on that one system with a very simple xaml. (see below)  Also, the crash doesn't happen with version 2018.2.620.45, only version 2018.3.1016.45 of Telerik.Windows.Controls.

<Window x:Class="GlyphTest.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <StackPanel>
            <telerik:RadGlyph Glyph="" Foreground="Black" FontSize="20" />
        </StackPanel>
    </Grid>
</Window>

 

0
Stefan
Telerik team
answered on 12 Dec 2018, 12:58 PM
Hi Joshua,

Thank you for the detailed report regarding the exception you are experiencing.

I tested the demonstrated setup on my end but was not able to reproduce the exception. For the time being my best guess is that this error lies in the MS font management core functionality. Despite that you mentioned that there are no updates install on the clients machine, can you please try installing the update mentioned in the first solution in the referred thread. Does this make any difference?

Regards,
Stefan
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Joshua
Top achievements
Rank 2
answered on 26 Dec 2018, 08:05 PM
I made an attempt to run the Microsoft patch, but it asked me to install .Net 4.7.1 which they don't have.  Their computer also isn't connected to the internet and is in constant use, so I will have to find a time to update it that won't interfere with production.  Long story short, for now I'm just using Telerik WPF controls version 2018.2.620.45, and will see if I can update their PC later and see if that helps, thanks.
0
Shaowu
Top achievements
Rank 1
answered on 23 Jun 2019, 06:11 AM

I am also having this problem on an old version of Windows 7 SP1 (kernel version: 6.1.7601.17514)

It can't be resolved by changing .NET versions and the exception message is different from the Microsoft one.

0
Accepted
Drago
Telerik team
answered on 24 Jun 2019, 02:20 PM

Hi Shaowu,

This issue is caused by a limitation in the glyph font (TelerikWebUI) and a bug in Windows 7 SP1. In general the font is not supported in some older versions of Windows 7 which means that, because they are using glyphs all the themes implemented after Office2013 won't work properly (Office2016, Fluent, Material, etc.).

There are several approaches that you can use to resolve this.

  •  Update the OS to Windows 7 SP2. The issue gets resolved with the installation of a certain Windows update, which we cannot pinpoint exactly. However the SP2 installation always help.

 

  • The second option is to download the UI for WPF source code, find the TelerikWebUI.ttf file and convert it to .otf using a third party tool (like FontForge for example). Then use a reflection to replace the font file, before the application startup. For example:
    Copy Code
    RadGlyph.GetRegisteredFonts();
    var dictionary = typeof(RadGlyph).GetField("registeredTypefaces", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null) as Dictionary<string, Typeface>;
    dictionary?.Clear();
     
    RadGlyph.RegisterFont(new FontFamily(new Uri("pack://application:,,,/WpfApp3;component/TelerikFont/", UriKind.RelativeOrAbsolute), "./#TelerikWebUI"), "TelerikWebUI");

    In the code snippet, "WpfApp3" is the assembly name of your project, and "TelerikFont" is a folder in your project, containing the converted font file. You can call this code in the OnStartup override of App.xaml.cs. Or before the InitializeComponent() call in the main window's constructor.

  • The last approach is to apply a different theme (Office2013 or older) if the exception occur.

    Copy Code
    protected override void OnStartup(StartupEventArgs e)
    {
        Typeface telerikFontTypeface = RadGlyph.GetTypeface("TelerikWebUI");
        try
        {
            // The getter of most properties of Typeface will throw an exception, if the type face cannot be evaluated properly.
            var capsHeight = telerikFontTypeface.CapsHeight;
        }
        catch(Exception)
        {
            this.Resources.MergedDictionaries.Clear();
            // Merge the resources of another Telerik theme using the approach from the help documentation.
        }
          
        base.OnStartup(e);
    }

Let me know if that helps or if you are still experiencing the issue.

Regards,

Dragan G
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Joshua
Top achievements
Rank 2
answered on 15 Jul 2019, 07:14 PM
Dragan G, thank you for this clear and concise summary of this issue!  I have been stuck on version 2018.2.620.45 ever since I first ran into this issue, but I experimented with your second approach of replacing the font and it seems to be working.  Thank you!!
0
Leland
Top achievements
Rank 1
answered on 11 Dec 2019, 03:46 PM
What KB?????? fixes this in Windows 7. We've been requiring our customers get the SP1 convenience rollup which...but we need to know exactly which one of the KB updates fixes this issue. Hopefully you or the community can help me out.
0
Dilyan Traykov
Telerik team
answered on 16 Dec 2019, 08:45 AM

Hello Leland,

Although we cannot say for certain which exact KB solves the issue, it is definitely resolved with the SP2.

Would your customers find it possible to update to this version of Windows 7 and if not, can you try any of the two other approaches Dragan suggested in his previous reply?

Regards,
Dilyan Traykov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Joshua
Top achievements
Rank 2
Answers by
Joshua
Top achievements
Rank 2
Stefan
Telerik team
Shaowu
Top achievements
Rank 1
Drago
Telerik team
Leland
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or