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

Application Crashing

7 Answers 1584 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Iron
Stefan asked on 12 May 2020, 04:24 AM

Hi,

I've got an application that is randomly crashing and it seems to be something with the xaml.

See below for the stack trace from the application - it doesn't seem to always happen. It's using implicit themes, I can't remember which one but its a mobile version. Is their a problem with my app or is it the xaml?

 

 

 

FATAL 2020-05-12 08:05:56,893 App                    UnhandledException - System.Windows.Markup.XamlParseException: 'Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.' Line number '4275' and line position '35'. ---> System.Exception: Cannot find resource named 'ToolTipStyle'. Resource names are case sensitive.
   at System.Windows.StaticResourceExtension.ProvideValueInternal(IServiceProvider serviceProvider, Boolean allowDeferredReference)
   at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
   --- End of inner exception stack trace ---
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadDeferredContent(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings parentSettings, Uri baseUri)
   at System.Windows.ResourceDictionary.CreateObject(KeyRecord key)
   at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.OnGettingValuePrivate(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.FetchResource(Object resourceKey, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean canCacheAsThemeResource, Boolean& canCache)
   at System.Windows.FrameworkElement.FindResourceInternal(FrameworkElement fe, FrameworkContentElement fce, DependencyProperty dp, Object resourceKey, Object unlinkedParent, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, DependencyObject boundaryElement, Boolean isImplicitStyleLookup, Object& source)
   at System.Windows.FrameworkElement.FindImplicitStyleResource(FrameworkElement fe, Object resourceKey, Object& source)
   at System.Windows.FrameworkElement.GetRawValue(DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry& entry)
   at System.Windows.FrameworkElement.EvaluateBaseValueCore(DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry& newEntry)
   at System.Windows.DependencyObject.EvaluateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry newEntry, OperationType operationType)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   at System.Windows.FrameworkElement.UpdateStyleProperty()
   at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
   at Telerik.Windows.Controls.ScreenTip.OnInitialized(EventArgs e)
   at System.Windows.FrameworkElement.TryFireInitialized()
   at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
   at System.Windows.FrameworkElement.AddLogicalChild(Object child)
   at System.Windows.Controls.Primitives.Popup.OnChildChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.Controls.Primitives.Popup.CreateRootPopupInternal(Popup popup, UIElement child, Boolean bindTreatMousePlacementAsBottomProperty)
   at System.Windows.Controls.ToolTip.HookupParentPopup()
   at System.Windows.Controls.ToolTip.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.Controls.PopupControlService.RaiseToolTipOpeningEvent(Boolean fromKeyboard)
   at System.Windows.Controls.PopupControlService.<>c__DisplayClass8_0.<InspectElementForToolTip>b__0(Object s, EventArgs e)
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

7 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 14 May 2020, 06:28 AM

Hello Stefan,

Thank you for the provided stack trace.

Looking at this stack trace, it seems that a resource with x:key="ToolTipStyle" is missing or cannot be found. May I ask you to double-check if you have such style with this key. If you have this style you can try to move inside the App.xaml file so that it can be accessed from files inside your application. 

Can you try the approaches above and let me know how it goes.

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Stefan
Top achievements
Rank 1
Iron
answered on 14 May 2020, 10:51 AM

<Style x:Key="ToolTipStyle" TargetType="ToolTip">

 

Its defined in a couple of places

System.windows.xaml

Telerik.Windows.Controls.RibbonView.xaml

Telerik.Windows.Controls.xaml

 

I've managed to reproduce it consistently now though. It happens when the mouse hovers over the caret button to hide the telerik Ribbon View but only in the Mobile theme. I'll play around with a bit to see if I can get it to work.

0
Stefan
Top achievements
Rank 1
Iron
answered on 14 May 2020, 10:58 AM

https://feedback.telerik.com/wpf/1355210-richtextbox-cannot-find-resource-named-tooltipstyle-exception-in-office2016-theme-noxaml

 

Also found this.

Xaml is a weak point for me, so not exactly sure how to fix. Any help would be appreciated but I will try some things to see if I can get it to work.

0
Stefan
Top achievements
Rank 1
Iron
answered on 14 May 2020, 11:02 AM

 

 

So I copied the ToolTipStyle from the RibbonView.xaml and placed it in the App.xaml file as a resource and the problem is fixed..

Not exactly sure why and what went wrong, however, its good enough for me for now.

 

 

 <Style x:Key="ToolTipStyle" TargetType="ToolTip">
        <Setter Property="FontFamily" Value="{telerik1:Office2016TouchResource ResourceKey=FontFamily}"/>
        <Setter Property="FontSize" Value="{telerik1:Office2016TouchResource ResourceKey=FontSize}"/>
        <Setter Property="Foreground" Value="{telerik1:Office2016TouchResource ResourceKey=MarkerBrush}"/>
        <Setter Property="Background" Value="{telerik1:Office2016TouchResource ResourceKey=MainBrush}"/>
        <Setter Property="BorderBrush" Value="{telerik1:Office2016TouchResource ResourceKey=BasicBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="6 6 6 5"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="ToolTip">
              <Border
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{telerik1:Office2016TouchResource ResourceKey=CornerRadius}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
              </Border>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>

0
Dinko | Tech Support Engineer
Telerik team
answered on 19 May 2020, 07:14 AM

Hello Stefan,

I am happy to hear that you have found a solution to your scenario. Still, I have tried to reproduce it but to no avail. Is it possible to share how you have set-up your application? Can you confirm that you are using Office2016Touch Theme? Which version of our controls are you referencing in your project? This way I can have a better look and see what I am missing on my side.

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Stefan
Top achievements
Rank 1
Iron
answered on 20 May 2020, 12:10 AM

I have it set up so the user can use 2 themes - I reference the noxaml binaries.

If the user selects desktop mode - I add the following resources - which I can't remember which theme I took those from - but it works fine, no crashing.

 

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Themes\Desktop\System.Windows.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Cloud.Controls.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Chart.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.ConversationalUI.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Data.xaml"/>
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.DataVisualization.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Diagrams.Extensions.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Diagrams.Ribbon.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Diagrams.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Docking.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Expressions.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.FileDialogs.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.FixedDocumentViewers.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.FixedDocumentViewersUI.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.GanttView.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.GridView.xaml"/>
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.ImageEditor.xaml"/>
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Input.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Media.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Navigation.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Pivot.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.PivotFieldList.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.RibbonView.xaml"/>
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.RichTextBoxUI.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.ScheduleView.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.Spreadsheet.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.SpreadsheetUI.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.SyntaxEditor.xaml"/>-->
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.VirtualGrid.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Controls.xaml"/>
    <!--<ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Documents.Proofing.xaml"/>-->
    <ResourceDictionary Source="/Themes\Desktop\Telerik.Windows.Documents.xaml"/>
    <ResourceDictionary Source="/Themes\Desktop\S3Ware.WPF.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <Style TargetType="telerik:AutoHideArea" BasedOn="{StaticResource AutoHideAreaStyle}">
    <Setter Property="IsTabStop" Value="False" />
  </Style>
  <Style TargetType="telerik:RadDocking" BasedOn="{StaticResource RadDockingStyle}">
    <Setter Property="IsTabStop" Value="False"/>
  </Style>
  <Style TargetType="telerik:RadGridResizer" BasedOn="{StaticResource RadGridResizerStyle}">
    <Setter Property="IsTabStop" Value="False"/>
  </Style>
  <Style TargetType="telerik:PaneHeader" BasedOn="{StaticResource PaneHeaderStyle}">
    <Setter Property="IsTabStop" Value="False"/>
  </Style>
  
</ResourceDictionary>

 

 

 

If the user selects the mobile theme I include the following xaml

 

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Themes\Mobile\System.Windows.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.RibbonView.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.Input.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.RichTextBoxUI.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.Data.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.DataVisualization.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.Docking.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.GridView.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Controls.Navigation.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\Telerik.Windows.Documents.xaml"/>
    <ResourceDictionary Source="/Themes\Mobile\S3Ware.WPF.xaml"/>
  </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

I add the theme by

 

Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(string.Format("Themes/{0}Theme.xaml", theme), UriKind.RelativeOrAbsolute) });

 

Where {0} is either desktop or mobile (depending on which one is selected)

From memory the mobile theme is office2016Touch

 

Hopefully that helps.

 

Stefan

0
Vladimir Stoyanov
Telerik team
answered on 22 May 2020, 02:31 PM

Hello Stefan,

Thank you for the shared code snippet. 

Can you check the order in which the ResourceDictionaries are merged on your end? Some dictionaries contain resources, which are used in other ones. You can refer to the Control Styles Dependencies article in our documentation, which lists the order in which the dictionaries should be added. 

Additionally, can you make sure that you are following the guidance of the following article: Switching Themes at Runtime for changing the themes? 

I hope you find this information helpful. 

Regards,
Vladimir Stoyanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Stefan
Top achievements
Rank 1
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Stefan
Top achievements
Rank 1
Iron
Vladimir Stoyanov
Telerik team
Share this question
or