Home Dashboard Directory Help

Silverlight throws AccessViolationException by HHristov



Sign in
to vote
Type: Bug
ID: 719572
Opened: 1/20/2012 4:55:14 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
User(s) can reproduce this bug


We found a problem in the Silverlight runtime. When we set Text property on a inherited TextBox which is unloaded then Silverlight throws an exception.

The problem seems to be related to the fact that TextBox is inherited and Foreground property which is animated using storyboard from a visual state.

There are two attachments - one with the project that could be used to reproduce the bug and the other one is a video demonstrating the problem.
Sign in to post a comment.
Posted by Microsoft on 7/15/2013 at 1:21 PM
Thank you for identifying this issue. We have fixed the problem, and the change is included in Silverlight 5 GDR3, released as part of MS13-052/KB2847559. You may download this fix at http://support.microsoft.com/kb/2847559. We are deeply appreciative for your commitment to help us build better products, and we hope this fix improves your experience with our tools and technologies.

The Silverlight Team
Posted by Aligned on 5/11/2012 at 7:40 AM
According to the release notes for the latest release, this has been resolved. Is that correct?
Posted by teyc on 4/15/2012 at 11:37 PM
I've provided another stack trace. In my case, I had a ComboBox inside a DataForm (wired up to Kyle McClellan's ComboBoxDataSource in Async mode). Upon changing the SelectedValue, AccessViolation is thrown. From the stack trace, it looks like a problem rebuilding the visual tree.
Posted by Hardaar on 4/3/2012 at 9:43 AM
Huge issue in our large business application when merging from SL4 -> SL5. See a workaround I added as it seems TextHinting could potentially be the big culprit in causing these to happen, as when I took it out in a part where it happened every time (100% reproducible) it stopped throwing these exceptions.
Posted by Jason Rosenthal on 3/28/2012 at 8:49 AM
I'm devistated by this problem as well. I'm not sure why the Silverlight team choose to relpace ver 4 with 5. Insead of running incompatible versions side by side. I haven't seen this type of problem since switching to .net from COM.
Posted by SoonerGoose on 3/27/2012 at 7:17 AM
My issue came with the adoption of the SL5 Runtime and using DataForm and the ReadOnlyTemplate template. To make the UI look the same from ReadOnlyTemplate to EditTemplate I use Textboxes for both but in the ReadOnlyTemplate the Textboxes are set to IsReadOnly="True". Then when I go to the EditTemplate by putting the DataForm in Edit mode and changed one of the Textbox's Text field it would throw the AccessViolationException in the NotifyPropertyChanged event. To fix this issue I put the IsReadOnly into a style and set this style in the TextBox. List so <TextBox Text="{Binding Name}" Style="{StaticResource ReadOnlyTextBoxStyle}" />. This fixed the initial issue. Next issue was putting the DataForm into edit mode, editting a TextBox, hitting cancel, put the DataForm back into edit mode and edit the TextBox again and the AccessViolationException popped up again in the NotifyPropertyChanged event. To fix this I requery the database on cancel. Not only does this keep the data fresh but it fixed the second issue I was having. Hope this helps anyone else having the same issue.
Posted by Adamoaragato on 3/13/2012 at 12:52 PM
This bug is very quirky. It does not happen all the time, but it happens consistently when I follow a certain work flow. More specifically, it happens when I switch tabs in a Telerik RadTabControl in Sliverlight.
Posted by Hugo86 on 3/8/2012 at 1:35 AM
We are having the same issue with SL5. What is the Status on this BUG?
Can we expect a fix in the near future?
Posted by eqs on 2/27/2012 at 11:03 AM
I wonder if this bug is really UI related, because any kind of NotifyPropertyChanged or RaiseDataMemberChanged can cause this bug. Except that it happens so randomly that it is impossible trace down.
Posted by PN Gandhi on 2/1/2012 at 1:23 AM
If we run our application in SL4 than its work fine. But if we run on SL5 than in some screens than "System.AccessViolationException: Attempted to read or write protected memory." error comes. Its a really big issue. If our end users get this error than we need to ask them to remove SL5 and install SL4 runtime.
Posted by MikeCousins on 1/25/2012 at 2:55 PM
Big issue for us. Our application is crashing all over the place for anybody using the Silverlight 5 runtime.
Posted by MS-Moderator07 [Feedback Moderator] on 1/22/2012 at 6:15 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 1/20/2012 at 5:43 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Hardaar on 4/3/2012 at 9:41 AM
I was debugging this like crazy (which was near impossible as the stack trace goes nowhere good) and noticed that a different theme caused this to NOT happen (it always happened under the JetPack theme). So I started commenting out parts of the JetPack theme XAML to see when or if it would stop happening. In the end I got to the Button XAML. On the Button XAML I found this:

<Setter Property="TextOptions.TextHintingMode" Value="Animated" />

Taking that line out caused the AccessViolationExceptions not to happen anymore. I have no idea what is going on with the TextHinting internally in SL 5, but clearly there must be some issue with it as taking this out seems to have solved the issue.

I truly hope this helps others too. I have yet to go through the rest of the application, and looking at the themes available from the toolkit I don't really see this used except for the Controls.Theming.SystemColors\Theme.xaml which has loads of them, and on the button it also has:

<Grid Cursor="Hand" TextOptions.TextHintingMode="Fixed">

My guess is that TextHinting plays a big part as this was also one of the big features of SL5 (that text renders much better). So for those running into this, try overriding the Button XAML in your theme and take out the text hinting and see if that solves it for you.
Posted by Ressouche Jean, SouchProd on 3/15/2012 at 2:30 AM
Before the binding context assignation, call the UpdateLayout() method of your controls.

ex assuming the Child1 & Child2 parents are visibility=collapsed:

LayoutRoot.DataContext = MyItemBinding;

Really dirty indeed, need a hotfix soon, not after 6 months !
File Name Submitted By Submitted On File Size  
AccessViolationExceptionTestProject.zip 1/20/2012 15 KB
video.zip 1/20/2012 769 KB
AccessViolationExceptionTestProject.zip 1/20/2012 15 KB
video.zip 1/20/2012 769 KB
AccessViolationSL5.txt 4/15/2012 3 KB