Skip to content

RichTextBox: Copy to Clipboard throws NotSupportedException #579

Closed
@jbe2277

Description

@jbe2277
  • .NET Core SDK: 3.0.100-preview5-011256 [e6f157e5a4]
  • Microsoft.WindowsDesktop.App 3.0.0-preview5-27610-56
  • VS 2019: 16.1.0 Preview 1.0
  • Windows version: Win10 1809 (Azure VM, connected via Remote Desktop)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Copy to Clipboard (e.g. press Ctrl+C) within the RichTextBox throws a NotSupportedException with the message: No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

Reproduce:

  • Clone https://github.com/jbe2277/waf.git
  • Checkout the netcoreapp3.0 branch
  • Open System.Waf.sln in VS 2019.
  • Set Samples/Writer/Writer.Presentation as start-up project
  • Start the application and click on New.
  • Insert some text, select the text and press Ctrl + C.

Expected: The selected text should be copied to the Clipboard. You could compare this with the master branch (targets .NET 4.6.1)

Actual: The application crashes.

Related issue: I get the same exception when I try to save the RichTextBox content as RTF file. Just press Save in the Writer application.

Details: Copy to Clipboard throws the exception:

System.NotSupportedException
  HResult=0x80131515
  Message=No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Text.Encoding.GetEncoding(Int32 codepage) in F:\workspace\_work\1\s\src\System.Private.CoreLib\shared\System\Text\Encoding.cs:line 287

System.Private.CoreLib.dll!System.Text.Encoding.GetEncoding(int codepage) Line 287
PresentationFramework.dll!System.Windows.Documents.FontTableEntry.ComputePreferredCodePage()
PresentationFramework.dll!System.Windows.Documents.XamlToRtfWriter.XamlToRtfWriter(string xaml)
PresentationFramework.dll!System.Windows.Documents.XamlRtfConverter.ConvertXamlToRtf(string xamlContent)
PresentationFramework.dll!System.Windows.Documents.TextEditorCopyPaste._CreateDataObject(System.Windows.Documents.TextEditor This, bool isDragDrop)
PresentationFramework.dll!System.Windows.Documents.TextEditorCopyPaste.Copy(System.Windows.Documents.TextEditor This, bool userInitiated)
PresentationCore.dll!System.Windows.Input.CommandBinding.OnExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
PresentationCore.dll!System.Windows.Input.CommandManager.ExecuteCommandBinding(object sender, System.Windows.Input.ExecutedRoutedEventArgs e, System.Windows.Input.CommandBinding commandBinding)
PresentationCore.dll!System.Windows.Input.CommandManager.FindCommandBinding(object sender, System.Windows.RoutedEventArgs e, System.Windows.Input.ICommand command, bool execute)
PresentationCore.dll!System.Windows.Input.CommandManager.OnExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target)
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised)
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args)
PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs args)
PresentationCore.dll!System.Windows.Input.RoutedCommand.ExecuteImpl(object parameter, System.Windows.IInputElement target, bool userInitiated)
PresentationCore.dll!System.Windows.Input.CommandManager.TranslateInput(System.Windows.IInputElement targetElement, System.Windows.Input.InputEventArgs inputEventArgs)
PresentationCore.dll!System.Windows.UIElement.OnKeyDownThunk(object sender, System.Windows.Input.KeyEventArgs e)
PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target)
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised)
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args)
PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs args)
PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea()
PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport inputReport)
PresentationCore.dll!System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(ref System.Windows.Interop.MSG msg, ref bool handled)
PresentationCore.dll!System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(ref System.Windows.Interop.MSG msg, System.Windows.Input.ModifierKeys modifiers)
PresentationCore.dll!System.Windows.Interop.HwndSource.OnPreprocessMessage(object param)
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs)
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler)
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs)
PresentationCore.dll!System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(ref System.Windows.Interop.MSG msg, ref bool handled)
WindowsBase.dll!System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(ref System.Windows.Interop.MSG msg)
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame)
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore)
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window)
Writer.dll!Waf.Writer.Presentation.App.Main()

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)regressionstatus: This issue is a regression from a previous build or release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions