Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.0.100-preview.7.24375.12] Text-Grab launch failed with exception System.Windows.Markup.XamlParseException at System.Windows.DependencyObject.EvaluateExpression #9475

Closed
Junjun-zhao opened this issue Jul 26, 2024 · 4 comments
Assignees
Labels
Investigate Requires further investigation by the WPF team.

Comments

@Junjun-zhao
Copy link
Member

Description

After the original bug [dotnet-sdk-9.0.100-preview.7.24352.8] WPF apps launch failed with exception 'Value cannot be null. (Parameter 'key')' fixed on dotnet-sdk-9.0.100-preview.7.24375.12, there is a new issue. The app still fails to be launched but it throws a new exception: System.Windows.Markup.XamlParseException: ''Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '17' and line position '18'.' We prepared the repro machine for your investigation. Please get the information from internal bug

Reproduction Steps

Debug Repro steps:
Please get the repro machine from the internal bug
1.Open "C:\ReproAppSource\Text-Grab\Text-Grab.sln" with Visual Studio.
2. Build the solution.
3. Update bin\Debug\net8.0-windows10.0.20348.0\Text-Grab.runtimeconfig to run against with dotnet-sdk-9.0.100-preview.7.24375.12:

"frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.7.24374.12"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.7.24375.4"
      }
  1. Press F5 to start the app.

Expected behavior

Expected Result:
App should be launched successfully.

Actual behavior

Actual Result:
App launch failed with exception thrown in Visual Studio:

System.Windows.Markup.XamlParseException: ''Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '17' and line position '18'.'
`
Inner Exception
InvalidOperationException: '#FF1C1C1C' is not a valid value for property 'Color'.

Stack Trace:
   at System.Windows.DependencyObject.EvaluateExpression(EntryIndex entryIndex, DependencyProperty dp, Expression expr, PropertyMetadata metadata, EffectiveValueEntry oldEntry, 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.ResourceReferenceExpression.InvalidateExpressionValue(Object sender, EventArgs e)
   at System.Windows.DependencyObject.OnInheritanceContextChanged(EventArgs args)
   at System.Windows.DependencyObject.ProvideSelfAsInheritanceContext(DependencyObject doValue, DependencyProperty dp)
   at System.Windows.ResourceDictionary.AddInheritanceContextToValues()
   at System.Windows.ResourceDictionary.set_Source(Uri value)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)

Regression?

Yes

Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.300: Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24375.12: Fail

Known Workarounds

No response

Impact

No response

Configuration

Application Name: Text-Grab
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-preview.7.24352.8
App or source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2173218

Github Link:
https://github.com/TheJoeFin/Text-Grab
Dotnet Info:

.NET SDK:
 Version:           9.0.100-preview.7.24375.12
 Commit:            9a99a3bf32
 Workload version:  9.0.100-manifests.57c130fb
 MSBuild version:   17.12.0-preview-24374-02+48e81c6f1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-preview.7.24375.12\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
  Version:      9.0.0-preview.7.24374.12
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  9.0.100-preview.7.24375.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-preview.7.24373.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.7.24374.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.7.24375.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other information

App Repro steps

  1. Open "C:\ReproApps\Text-Grab\Text-Grab.runtimeconfig.json" file .
  2. Change the "Text-Grab.runtimeconfig" file to let the app run against with dotnet-sdk-dotnet-sdk-9.0.100-preview.7.24375.12.
"frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.7.24374.12"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.7.24375.4"
      }
  1. Launch Text-Grab.exe.

Expected Result:
Launch successfully.

Actual Result:
Launch failed.
Open Event Viewer, we can see below detailed stack trace message:

Application: Text-Grab.exe
CoreCLR Version: 9.0.24.37412
.NET Version: 9.0.0-preview.7.24374.12
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException: Set property 'System.Windows.ResourceDictionary.Source' threw an exception.
 ---> System.InvalidOperationException: '#FF1C1C1C' is not a valid value for property 'Color'.
   at System.Windows.DependencyObject.EvaluateExpression(EntryIndex entryIndex, DependencyProperty dp, Expression expr, PropertyMetadata metadata, EffectiveValueEntry oldEntry, 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.ResourceReferenceExpression.InvalidateExpressionValue(Object sender, EventArgs e)
   at System.Windows.DependencyObject.OnInheritanceContextChanged(EventArgs args)
   at System.Windows.DependencyObject.ProvideSelfAsInheritanceContext(DependencyObject doValue, DependencyProperty dp)
   at System.Windows.ResourceDictionary.AddInheritanceContextToValues()
   at System.Windows.ResourceDictionary.set_Source(Uri value)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
   --- End of inner exception stack trace ---
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at Text_Grab.App.InitializeComponent() in C:\Users\v-shisheng\Desktop\Text-Grab\Text-Grab\App.xaml:line 1
   at Text_Grab.App.Main()

Findings:
This is also "System.Windows.Markup.XamlParseException" exception, which is similar with bug [dotnet-sdk-9.0.100-preview.7.24352.8] WPF apps launch failed with System.Windows.Markup.XamlParseException, but the stack trace is different. It is thrown at ``System.Windows.DependencyObject.EvaluateExpression(EntryIndex entryIndex, DependencyProperty dp, Expression expr, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry newEntry)```

@dotnet-actwx-bot @dotnet/compat

@Junjun-zhao
Copy link
Member Author

@harshit7962 There is a new issue for app Text-Grab after the fix, could you please help look into it?

@harshit7962
Copy link
Member

harshit7962 commented Aug 2, 2024

@Junjun-zhao, as discussed, the bug is reproduced if an application uses a DynamicResource incorrectly.
With our changes to deal with dynamic resources to enhance performance, we have enforced the applications to crash if such practice is employed. In this specific case, a similar error was thrown at a different point in time and was consumed during the runtime and hence the crash did not occur.

This does not stand as a blocker for .NET 9, preview 7 release and developers can mitigate this crash on their end. Although, we are in process of providing an opt-out switch to this in rc1 release that would ease in mitigating the crash.

@dipeshmsft
Copy link
Member

Closing this as the fix for this has been merged in .NET 9 RC1

@Junjun-zhao
Copy link
Member Author

Verifying with opt-out switch for DynamicResource optimization(Related PR) on RC1 build dotnet-sdk-9.0.100-rc.1.24422.10 and latest dotnet-sdk-9.0.100-rc.1.24426.13, Text-Grab app is able to launch successfully( Set "Switch.System.Windows.Controls.DisableDynamicResourceOptimization" to true).

Either one of the two options will work.
Option1: Add the switch in Text-Grab.runtimeconfig.json file.

{
......
    "configProperties": {
      "Switch.System.Windows.Controls.DisableDynamicResourceOptimization": true,
      ......
    }
  }
}

Option2:
Including this in the project configurations (.csproj)

<ItemGroup>
<RuntimeHostConfigurationOption Include="
Switch.System.Windows.Controls.DisableDynamicResourceOptimization
" Value="true" />
</ItemGroup>

@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

3 participants