Skip to content

[dotnet-sdk-6.0.100-rc.1.21401.2] System.Windows.Markup.XamlParseException when reading resource file in ProyectoFinalAplicada1 #4987

@Junjun-zhao

Description

@Junjun-zhao

Application Name: ProyectoFinalAplicada1
OS: Windows 10 RS5
CPU: X64
.NET Build Number: dotnet-sdk-6.0.100-rc.1.21401.2

Verify Scenarios:
1). Windows10 rs5 x64 + dotnet-sdk-6.0.100-rc.1.21401.2: Fail
2). Windows10 rs5 x64 + dotnet-sdk-6.0.100-rc.1.21402.7: Fail
3). Windows10 rs5 x64 +dotnet-sdk-6.0.100-preview.7.21379.14 : Pass
4).Windows10 rs5 x64 + dotnet-sdk-3.1.411: Pass

App and App Source checking at : https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1364942

Repro steps:

This is 3.1 app, but we are running it on 6.0, machine only have 6.0 installed, and DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2, so it runs on 6.0

1.Launch application “ProyectoFinalAplicada1.exe”.

Expected Result:
The app is launched successfully.

Actual Result:
Fail to launch the app, app is crashed.

Exception Details:

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message='Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '9'.
  Source=PresentationFramework
  StackTrace:
   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 ProyectoFinalAplicada1.MainWindow.InitializeComponent() in D:\ProyectoFinalAplicada1\ProyectoFinalAplicada1\MainWindow.xaml:line 1

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
DirectoryNotFoundException: Could not find a part of the path 'D:\ProyectoFinalAplicada1\ProyectoFinalAplicada1\bin\Debug\netcoreapp3.1\ProyectoFinalAplicada1.dll\Resources\Window.png'.

Minimal Repro steps:

  1. Create WPF Application (any framework, but we need to run on .net6)
  2. Add png file as a resource, Set BuildAction to Content, set BuildAction to copy always
  3. Set resource file as an Icon to MainWindow.xaml, such as :
<Window x:Class="WpfApp2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp2"
        mc:Ignorable="d"
        Icon="/Resources/Window.png"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
    </Grid>
</Window>
  1. Build and Run

Expected Result:

It should display the app window with icon

Actual Result:
Fails when we run against 6.0.100-rc.1.21401.2, works as expected on earlier runtimes.
Can not open and throw an Exception

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message='Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '6' and line position '9'.
  Source=PresentationFramework
  StackTrace:
   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 WpfApp2.MainWindow.InitializeComponent() in C:\Users\Appcompat\source\repos\WpfApp2\WpfApp2\MainWindow.xaml:line 1

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Appcompat\source\repos\WpfApp2\WpfApp2\bin\Debug\netcoreapp3.1-windows7.0\WpfApp2.dll\Resources\Window.png'.

Additional Information:
There are total 5 apps failed by this issue, here is the list:
ProyectoFinalAplicada1
MultiRPC
ReloadedWPF
BigBoxGameCatalog
PresentationThemeAero

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)urgentstatus: This issue needs immediate attention

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions