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

RichTextBox throws XamlParseException in its constructor #1178

Closed
Nukepayload2 opened this issue Jul 5, 2019 · 10 comments
Closed

RichTextBox throws XamlParseException in its constructor #1178

Nukepayload2 opened this issue Jul 5, 2019 · 10 comments
Labels
Bug Product bug (most likely)
Milestone

Comments

@Nukepayload2
Copy link

  • .NET Core Version: 3.0 preview 6
  • Windows version: Windows 10 x64 zh-CN 18362.207
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:
The constructor of RichTextBox crashes when running on Windows 10 1903 Chinese Simplified.
Similar to #1003

Actual behavior:
($exception).StackTrace

 An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Private.CoreLib.dll
“对类型“System.Windows.Controls.RichTextBox”的构造函数执行符合指定的绑定约束的调用时引发了异常。”,行号为“10”,行位置为“10”。

DirectCast(($exception)._innerException, System.ArgumentException).Message

Requested value '删除' was not found.

($exception)._innerException.StackTrace

   at System.Enum.TryParseByName(RuntimeType enumType, String originalValueString, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, UInt64& result)
   at System.Enum.TryParseInt32Enum(RuntimeType enumType, String originalValueString, ReadOnlySpan`1 value, Int32 minInclusive, Int32 maxInclusive, Boolean ignoreCase, Boolean throwOnFailure, TypeCode type, Int32& result)
   at System.Enum.TryParse(Type enumType, String value, Boolean ignoreCase, Boolean throwOnFailure, Object& result)
   at System.Enum.Parse(Type enumType, String value, Boolean ignoreCase)
   at System.Windows.Input.KeyConverter.GetKey(String keyToken, CultureInfo culture)
   at System.Windows.Input.KeyConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object source)
   at System.Windows.Input.KeyGestureConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object source)
   at System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text)
   at System.Windows.Input.KeyGesture.CreateFromResourceStrings(String keyGestureToken, String keyDisplayString)
   at MS.Internal.Commands.CommandHelpers.RegisterCommandHandler(Type controlType, RoutedCommand command, ExecutedRoutedEventHandler executedRoutedEventHandler, CanExecuteRoutedEventHandler canExecuteRoutedEventHandler, String srid1, String srid2)
   at System.Windows.Documents.TextEditorTyping._RegisterClassHandlers(Type controlType, Boolean registerEventListeners)
   at System.Windows.Documents.TextEditor.RegisterCommandHandlers(Type controlType, Boolean acceptsRichContent, Boolean readOnly, Boolean registerEventListeners)
   at System.Windows.Controls.RichTextBox..ctor(FlowDocument document)
   at System.Windows.Baml2006.WpfSharedBamlSchemaContext.<>c.<Create_BamlType_RichTextBox>b__923_0()
   at System.Windows.Baml2006.WpfKnownTypeInvoker.CreateInstance(Object[] arguments)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(XamlType xamlType, Object[] args)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)

Expected behavior:
RichTextBox should not throw exception.

Minimal repro:
Drag a RichTextBox control into MainWindow.xaml.

<Window x:Class="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:RichTextTest"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <RichTextBox/>
    </Grid>
</Window>
@weltkante
Copy link

This should be fixed by #919. I don't know when the next preview will be released but if you don't want to wait you could try nightly builds as described here or you can work around the bug by setting the culture to english during startup (CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");).

@grubioe
Copy link
Contributor

grubioe commented Jul 8, 2019

@Nukepayload2 please use the nightly build to confirm that this is fixed.

@grubioe grubioe added Bug Product bug (most likely) 📭 waiting-author-feedback To request more information from author. labels Jul 8, 2019
@grubioe grubioe added this to the 3.0 milestone Jul 8, 2019
@weltkante
Copy link

what happened to preview7 anyways, considering the downloads are still on preview6 but nightlies are already on preview8 ?

@vatsan-madhavan
Copy link
Member

P7 is in validation now - should be announced as soon as it’s signed off by all teams.

@vatsan-madhavan
Copy link
Member

vatsan-madhavan commented Jul 9, 2019

/cc @jamshedd , @leecow

@Nukepayload2
Copy link
Author

@grubioe
I don't know whether this issue has been fixed, because my program crashed before calling the constructor of RichTextBox.

image

I'll try again after #1183 is solved.

@jamshedd
Copy link
Member

jamshedd commented Jul 9, 2019

@weltkante, as you noticed master has moved on to Preview 8, this is because the Preview 7 release is in lock down (final stabilization). Preview 7 will be available very soon (next couple of weeks).

@vatsan-madhavan
Copy link
Member

@Nukepayload2 you are hitting #1183

@vatsan-madhavan
Copy link
Member

From #1183 (comment)

This is now fixed in the latest build available at https://github.com/dotnet/core-sdk.

The current version which I just I checked is:

fc226794a12bfcfc18bac269bc57c7900e4a1e5d
3.0.100-preview8-012990

Please try the latest SDK - you should no longer get the TypeLoadException related to XamlAccessLevel.

@Nukepayload2
Copy link
Author

It's fixed in the latest SDK.

@dotnet dotnet locked as resolved and limited conversation to collaborators Apr 16, 2022
@dipeshmsft dipeshmsft removed the 📭 waiting-author-feedback To request more information from author. label Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Product bug (most likely)
Projects
None yet
Development

No branches or pull requests

6 participants