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

When using .NET9 pre7 build and run, will throw System.Windows.Markup.XamlParseException #9582

Closed
ssccinng opened this issue Aug 16, 2024 · 19 comments
Labels
Investigate Requires further investigation by the WPF team.

Comments

@ssccinng
Copy link

Description

image

When using the above code, an error will be thrown

System.Windows.Markup.XamlParseException
HResult=0x80131501
Message=“在“System.Windows.StaticResourceExtension”上提供值时引发了异常。”,行号为“12”,行位置为“10”。
Source=PresentationFramework
StackTrace:
在 System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
在 System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
在 System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
在 WpfBugTest.MainWindow.InitializeComponent() 在 D:\wcsrepo\WpfBugTest\MainWindow.xaml 中: 第 1 行

此异常最初是在此调用堆栈中引发的:
[外部代码]

内部异常 1:
IndexOutOfRangeException: Index was outside the bounds of the array.

Reproduction Steps

https://github.com/ssccinng/WpfBugTest

Run it using the latest preview version

Please note that this error does not occur when selecting net9 for the targetframework, but only when selecting net8
net8.0-windows

Expected behavior

not throw error

Actual behavior

throw error

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

@singhashish-wpf singhashish-wpf added the Investigate Requires further investigation by the WPF team. label Aug 16, 2024
@heku
Copy link

heku commented Aug 16, 2024

I got same issue after upgrading my VS2022 preview to latest, my workaroud is installing .NET 8 SDK and adding a global.json to force .NET SDK to version 8.

@Taiizor
Copy link

Taiizor commented Aug 16, 2024

When the project is compiled with .NET 9 Preview 7, it only runs successfully with .NET 9. Unfortunately, it encounters errors on lower versions.

@pchaurasia14
Copy link
Member

pchaurasia14 commented Aug 16, 2024

@ssccinng @heku @Taiizor - Thanks for the report.

We have a candidate fix already in place for addressing this issue - #9584

@Taiizor
Copy link

Taiizor commented Aug 16, 2024

@heku @Taiizor - Thanks for the report.

We have a candidate fix already in place for fixing this issue - #9584

So, will there be an interim release of .NET 9 to fix this, or do we need to wait until the .NET 9 RC version?

@pchaurasia14
Copy link
Member

We are working out the logistics on this one. Currently awaiting approval from .NET.
I'll keep this thread posted on updates.

@melytc
Copy link

melytc commented Aug 16, 2024

My team is also being impacted by this. Commenting to get notified of any update! cc: @haileymck

@Jakedahl94
Copy link

I am having this issue after upgrading VS this week.

@singhashish-wpf
Copy link
Member

Apologies for the inconvenience. This happened because of regression of Setter.Value ContentProperty change.
We have reverted the changes and the changes are included in RC1 builds, this will be reflected in RC1.
There are two workarounds for now:

  • Use global.json and pin the dotnet sdk version to 8. Something like below:
{
  "sdk": {
    "version": "8.0.300"
  },
}
  • Use RC1 nightly builds - The builds which have the reverted changes included.

@AlanHauge-Interacoustics

This also happens in .NET framework 4.8, so it might not be isolated to .NET 9

@i2van
Copy link

i2van commented Aug 19, 2024

This also happens in .NET framework 4.8, so it might not be isolated to .NET 9

global.json can be used as WA:

{
  "sdk": {
    "version": "8.0.107",
    "rollForward": "latestFeature"
  }
}

@majocha
Copy link

majocha commented Aug 25, 2024

This is affecting Visual F# Tools extension and probably many other Visual Studio extensions using WPF as they target net472:
dotnet/fsharp#17602

dotnet/fsharp#17602 (comment)

@pfre017
Copy link

pfre017 commented Sep 13, 2024

We are working out the logistics on this one. Currently awaiting approval from .NET. I'll keep this thread posted on updates.

I have the VS 17.12.0 Preview 2 and 9.0.100-rc.1.24452.12 [C:\Program Files\dotnet\sdk], but still get the same issue? I thought this was resolved in rc1?

@singhashish-wpf
Copy link
Member

@pfre017 I am unable to repro with the VS and dotnet versions mentioned. I am trying to repro with the sample repro mentioned in the issue description. Attached is a video. Let me know if there is something different with your setup or repro.
https://github.com/user-attachments/assets/a22c0690-5f69-4d2e-9d12-bb0fe29f6087

@AlanHauge-Interacoustics

@pfre017 I am unable to repro with the VS and dotnet versions mentioned. I am trying to repro with the sample repro mentioned in the issue description. Attached is a video. Let me know if there is something different with your setup or repro. https://github.com/user-attachments/assets/a22c0690-5f69-4d2e-9d12-bb0fe29f6087

I got it with a .NET framework 4.8 application

@singhashish-wpf
Copy link
Member

singhashish-wpf commented Sep 13, 2024

@pfre017 I am unable to repro with the VS and dotnet versions mentioned. I am trying to repro with the sample repro mentioned in the issue description. Attached is a video. Let me know if there is something different with your setup or repro. https://github.com/user-attachments/assets/a22c0690-5f69-4d2e-9d12-bb0fe29f6087

I got it with a .NET framework 4.8 application

@AlanHauge-Interacoustics Could you share your repro sample?

@singhashish-wpf
Copy link
Member

I converted the same repro to a netfx 4.8 app and couldn't repro. There is a difference in the way we are trying to repro it. Share your repro samples and other details, so that we can take it up further.
@AlanHauge-Interacoustics @pfre017

@DaveInCaz
Copy link

Same problem here but using NET48 and VS2022 Version 17.12.0 Preview 1.0.

@pfre017
Copy link

pfre017 commented Sep 24, 2024

@pfre017 I am unable to repro with the VS and dotnet versions mentioned. I am trying to repro with the sample repro mentioned in the issue description. Attached is a video. Let me know if there is something different with your setup or repro. https://github.com/user-attachments/assets/a22c0690-5f69-4d2e-9d12-bb0fe29f6087

Thank you @singhashish-wpf. I have now got it to work. I suspect it was a my own NUGET package that was built with an old version of .net 9.0

@singhashish-wpf
Copy link
Member

Nice @pfre017 !
Thanks for the confirmation.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 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

13 participants