Skip to content

MS.Internal.Invariant.get_IsDialogOverrideEnabled() can throw NullReferenceException #6772

Closed

Description

@VladimirKhil
  • .NET Core Version: 6.0

I have only the exception stack trace collected automatically from one of my clients. No other system information is available.

I hope that this stack trace would be useful for some research.

According to sources, IsDialogOverrideEnabled could throw NRE if registry key "Software\Microsoft\.NETFramework" is missing on the machine.

System.NullReferenceException: Object reference not set to an instance of an object. at bool MS.Internal.Invariant.get_IsDialogOverrideEnabled() at void MS.Internal.Invariant.Assert(bool condition) at IFontFamily System.Windows.Media.FontFamily.get_FirstFontFamily() at double System.Windows.Media.FontFamily.get_LineSpacing() at double System.Windows.Controls.TextBox.GetLineHeight() at void System.Windows.Controls.TextBox.SetScrollViewerMinMaxHeight() at Size System.Windows.Controls.TextBox.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size System.Windows.Controls.DockPanel.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size System.Windows.Controls.DockPanel.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) at Size System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size Microsoft.Windows.Themes.ClassicBorderDecorator.MeasureOverride(Size availableSize) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size System.Windows.Controls.Grid.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at void System.Windows.Controls.Grid.MeasureCell(int cell, bool forceInfinityV) at void System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV, out bool hasDesiredSizeUChanged) at Size System.Windows.Controls.Grid.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size System.Windows.Controls.Control.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at void System.Windows.Controls.Grid.MeasureCell(int cell, bool forceInfinityV) at void System.Windows.Controls.Grid.MeasureCellsGroup(int cellsHead, Size referenceSize, bool ignoreDesiredSizeU, bool forceInfinityV, out bool hasDesiredSizeUChanged) at Size System.Windows.Controls.Grid.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size System.Windows.Controls.Grid.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) at Size System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size System.Windows.Controls.Border.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size System.Windows.Controls.Control.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at Size MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint) at Size System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint) at Size System.Windows.FrameworkElement.MeasureCore(Size availableSize) at void System.Windows.UIElement.Measure(Size availableSize) at void System.Windows.ContextLayoutManager.UpdateLayout() at object System.Windows.ContextLayoutManager.UpdateLayoutCallback(object arg) at void System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at void System.Windows.Media.MediaContext.RenderMessageHandlerCore(object resizedCompositionTarget) at object System.Windows.Media.MediaContext.RenderMessageHandler(object resizedCompositionTarget) at object System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, object args, int numArgs) at object System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, Delegate callback, object args, int numArgs, Delegate catchHandler)

Activity

  1. added
    Investigate
    on Jul 11, 2022
  2. singhashish-wpf commented on Jul 11, 2022

    @singhashish-wpf
    Contributor

    @VladimirKhil While it is true that there could be NRE if the Registry key isn't present, and the remediation could be as simple as a null check, Will it be possible for to update the issue with a minimal repro and would you be interested in submitting a PR?

  3. VladimirKhil commented on Jul 11, 2022

    @VladimirKhil
    ContributorAuthor

    @VladimirKhil While it is true that there could be NRE if the Registry key isn't present, and the remediation could be as simple as a null check, Will it be possible for to update the issue with a minimal repro and would you be interested in submitting a PR?

    Unfortunately I do not know how to reproduce this issue in real environment. The only way that I can suggest is to create a Unit test with mocked Registry which could cause the error.

    Yes, I can try to submit a PR.

  4. lindexi commented on Jul 12, 2022

    @lindexi
    Member

    I can sure the win7 (since 2013) has created the Software\Microsoft\.NETFramework register key. We can ignore this error in .NET Framework, because if the system has this error, it will not be able to start the application. But now that we use .NET Core, I will no longer require .NET Framework to be installed correctly on the system.

  5. VladimirKhil commented on Jul 12, 2022

    @VladimirKhil
    ContributorAuthor

    I have created a PR: #6785

  6. added
    Bug
    and removed on Jul 13, 2022
  7. ghost locked as resolved and limited conversation to collaborators on Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugInvestigate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions