Silverlight 5 AccessViolationException

旧城冷巷雨未停 提交于 2019-12-01 23:36:10

问题


I installed the Silverlight 5 VS 2010 tools and the 64-bit Developer runtime and now I get a System.AccessViolationException when I do a specific action. The projects are still Silverlight 4, I haven't upgraded them. I verified on another developer's computer (who doesn't have SL5 installed yet) that the same code still works in SL4. The message is:{System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.} and it kills IE. It's happening after a delete confirmation ChildWindow's ok button is clicked and my breakpoint in the ok action event is not hit (the other delete confirmations I have, using the similar code do not have this problem). The stack trace points to

System.Windows.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase obj = {Telerik.Windows.Controls.RadWatermarkTextBox}, System.Windows.DependencyProperty property, string s) + 0x6f bytes    

VS is pointing to my RadDateTimePicker custom style: "BindingDebugging!RadDateTimePickerxaml_2.BindingOperation_1100_562(object BindingState = {System.Windows.Data.Debugging.BindingDebugState}) Line 1 + 0x11 bytes Unknown"

I removed the style from the controls and the App.xaml and still get an exception... This time it points to a Telerik theme "The debugger will ask the user to find the file: Telerik.Windows.Controls.Input;Component\Themes\Office\Black\DateTimePicker.xaml"

My coworker mentioned that he saw the same exception in Silverlight when he sent in some malformed XAML to an XMLWriter.

I'll add more information as I find it.

Anybody know what to look for specifically in that style file?

EDIT: I've seen this in a few places now, not just connected to the DateTimePicker. I cross posted this at http://forums.silverlight.net/p/245247/613094.aspx/1?p=True&t=634600762692144367.

I also get this exception with this stack trace. It doesn't happen every time, but it is when I'm changing the width of a rectangle using a RadNumericUpDown and the RaisePropertyChanged("Width") is called: >

System.Windows.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase obj = {Telerik.Windows.Controls.PickerTextBox}, System.Windows.DependencyProperty property, string s) + 0x6f bytes  
    System.Windows.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase doh, System.Windows.DependencyProperty property, object obj) + 0x2ce bytes  
    System.Windows.dll!System.Windows.DependencyObject.SetObjectValueToCore(System.Windows.DependencyProperty dp, object value) + 0xd6 bytes    
    System.Windows.dll!System.Windows.DependencyObject.SetEffectiveValue(System.Windows.DependencyProperty property = {System.Windows.CoreDependencyProperty}, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, object newValue = "103") + 0x35 bytes    
    System.Windows.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty property = {System.Windows.CoreDependencyProperty}, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, System.Windows.DependencyObject.ValueOperation operation) + 0xe6 bytes  
    System.Windows.dll!System.Windows.DependencyObject.SetValueInternal(System.Windows.DependencyProperty dp, object value, bool allowReadOnlySet, bool isBindingInStyleSetter) + 0x248 bytes   
    System.Windows.dll!System.Windows.Controls.TextBox.Text.set(string value) + 0x33 bytes  
    Telerik.Windows.Controls.Input!Telerik.Windows.Controls.RadNumericUpDown.UpdateText() + 0x50 bytes  
    Telerik.Windows.Controls.Input!Telerik.Windows.Controls.RadNumericUpDown.OnValueChanged(Telerik.Windows.Controls.RadRangeBaseValueChangedEventArgs e = {Telerik.Windows.Controls.RadRangeBaseValueChangedEventArgs}) + 0xd6 bytes   

EDIT #2: this seems related: http://forums.silverlight.net/p/178858/402638.aspx

EDIT #3: I have not been able to reproduce this outside of my project. I also haven't stopped this from happening by commenting out UserControls and sections of code. I've even removed the binding from the XAML and the RadNumericUpDown that it seems to be connected to. I haven't removed our custom styles yet, maybe that's something to try next... Does anyone know how I can reproduce this and work from there?

EDIT #4: They fixed it with the latest version according to: http://10rem.net/blog/2012/05/09/silverlight-51104110-released-today


回答1:


I'm seeing this exception when databinding to a hidden element. We have some fields that are visible or not based on some databinding, but both of those fields are updated with another databinding. When the RaisePropertyChanged is fired on the hidden field we get the AccessViolationException. I had to add some checks to my code to suppress the RaisePropertyChanged when the control isn't visible.




回答2:


We "were" experiencing this problem after updating to Silverlight 5. The AccessViolationException was being thrown when setting (sender as RadComboBox).ItemsSources during the loading event of various controls. This error was difficult to reproduce and did not always throw under identical test conditions. However, I believe the best work around is as follows:

Silverlight 4:

(sender as RadComboBox).ItemsSource = OurClass.MakeOurList();

The issues disappeared when I added...

Silverlight 5:

(sender as RadComboBox).UpdateLayout();

(sender as RadComboBox).ItemsSource = OurClass.MakeOurList();

I am sure this is a "work around" at best, and hope to hear a better solution. But for now we are back up and running!




回答3:


There is a Microsoft Connect bug report for the same problem that we submitted a couple of hours ago. Please, vote so that it could be fixed as soon as possible.

RadComboBox already contains a workaround so please, check the latest internal build under your account and let us know if the problem persists. Here is the Telerik forum thread about the same problem.

I hope this helps.




回答4:


I've updated the DateTimePicker.xaml for my custom Theme to use Microsoft’s Textbox vs. RadWatermarkText as my workaround. The crashing has stopped however the watermark feature is obviously gone.

I downloaded a theming project from Telerik about a year ago so I could make their controls look almost as good as the default ones. If any of you wish to do the same as I then you'll find DateTimePicker.xaml in their download.

I found the Telerik controls to be too buggy for my taste so I choose not to continually pay them for bug fixes via subscription.




回答5:


I finally tracked down my specific problem. It was only happening with an element after my inherited ChildWindow.

I had this hack that was trying to fix a bug I had a few months ago. Once I removed it, the exception stopped happening. I'm pretty certain I don't need the hack anymore because of improvements elsewhere, so it's a double bonus! I tried in several places to marshal the calls back to the UI thread, but something in the timer (which is supposed to be on the UI thread) was not allowing it (that's my theory). Good luck to everyone looking for the answer. +1 for the ones so far!

this.Closed += (s, e) =>
{
var timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(.25);
timer.Tick += (object senderTimer, EventArgs eTimer) =>
{
    timer.Stop();

    // without the timer, the content will disappear before the window closes
    this.contentHolder.Child = null;
};

timer.Start();
};

I wasn't able to reproduce this with a ChildWindow in a separate project. So this answer isn't that useful.



来源:https://stackoverflow.com/questions/8495242/silverlight-5-accessviolationexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!