question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AccessViolationException when setting character format in RichEditBox

See original GitHub issue

Hello, I’m not sure whether this is the right place to post this issue, but I’ve been having some problems (as well as many other users) with the RichEditBox control since WinRT came out, and not those problems have persisted on UWP.

In my case, I’m getting a System.AccessViolationException when setting the character format of a text range. Here’s a screen. There are two problems:

  1. An AccessViolationException is a low level exception that just can’t be caught with managed code, so I don’t think a control from the official framework like the RichEditBox is ever supposed to throw one of these exceptions.
  2. As you can see, the loop index here is 1103, and it changes every time, sometimes it works fine, sometimes it crashes at a different position, it just seems to happen at random.

I’ve also had other exceptions like that with the same RichEditBox control, for example when setting some text with the SetText method, and I’ve seen many other users complaining about similar issues in the past (see here and here).

The thing here is that it seems like the RichEditBox control has had some bugs since the Windows Phone 8.1 days that nobody has ever fixed throughout all these years, and they are now present in Windows 10 as well.

Is there a workaround you can suggest for this specific crash I’m having? I don’t even understand why is it happening, I’m just setting the color of a selected range.

And also, could you let the team that works on this control that right now it’s not perfectly reliable and has a few issues? I hope this feedback might be useful to them! 😄

Thanks in advance for your help!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
stmoycommented, Oct 10, 2017

Thank you again for your help identifying and isolating this bug. We believe that we have fixed both this issue and the one mentioned here, as both stemmed from the same issue.

This fix should be coming your way in an upcoming Windows Insider build post-Fall Creators Update (build numbers higher than 17000+). Please reach out if you find that this issue still hits.

1reaction
sidprasadcommented, Jul 26, 2017

@Sergio0694

Hi Sergio,

Thank you for the crash dumps! I’m still unable to internally repro the bug. It may be that there are differences between my setup and yours. I was hoping you could tell me what language packs you have installed on the machine, as well as what your default language is.

Thank you again for raising the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - AccessViolationException when setting the Text in a ...
If I use only the buttons, like this one, it works fine and the characters gets added inside the RichEditBox. What doesn't work:....
Read more >
AccessViolationException when setting character format in ...
Hi Sergio, I am a developer who works on RichEditBox . I'm having some trouble replicating the crash you mentioned, and would appreciate...
Read more >
'Attempted to read or write protected memory. This is often ...
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'.
Read more >
Re: Assign Value in DropDownList type Combo Box - C# ...
Answer, Re: Problem with quicktime component (System.AccessViolationException) Pin. combo_ci15-Jun-07 23:25. combo_ci, 15-Jun-07 23:25 ...
Read more >
[Vb.Net]-Formatting Richtextbox in WPF
It is an event handler that is wired to a 'Format code block' button. The handler shors how to get the selected text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found