C# 试图读取或写入受保护的内存。这通常表示其他内存已损坏
像很多这样的主题一样,到目前为止,我有一个问题,这个异常发生在一个特定的地方(5%的时间)和其他地方 第一行代码是C# 试图读取或写入受保护的内存。这通常表示其他内存已损坏,c#,silverlight,telerik,dataform,C#,Silverlight,Telerik,Dataform,像很多这样的主题一样,到目前为止,我有一个问题,这个异常发生在一个特定的地方(5%的时间)和其他地方 第一行代码是 ((DefinitionDetailForm.FindNameInContent("DataFieldDefinitionPoints") as DataField). FindName("DefinitionScoringPoints") as RadNumericUpDown).
((DefinitionDetailForm.FindNameInContent("DataFieldDefinitionPoints") as DataField).
FindName("DefinitionScoringPoints") as RadNumericUpDown).
Minimum = 0;
首先,我认为我可能需要将引用保存在字段中,但这也没有帮助
另一种情况是在一个未定义的位置,我甚至在调用堆栈中没有得到任何信息,因此我无法提供更多信息:(
有人至少对第一个有想法吗
编辑:
当东西损坏时调用stack
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase obj, 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, ref System.Windows.EffectiveValueEntry newEntry, object newValue) + 0x35 bytes
System.Windows.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty property, 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() + 0xa5 bytes
Telerik.Windows.Controls.Input!Telerik.Windows.Controls.RadNumericUpDown.OnValueChanged(Telerik.Windows.Controls.RadRangeBaseValueChangedEventArgs e) + 0x1f5 bytes
Telerik.Windows.Controls!Telerik.Windows.Controls.RadRangeBase.OnValueChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x105 bytes
Telerik.Windows.Controls!Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x58b bytes
System.Windows.dll!System.Windows.DependencyObject.RaisePropertyChangeNotifications(System.Windows.DependencyProperty dp, object oldValue, object newValue) + 0x53 bytes
System.Windows.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty property, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, System.Windows.DependencyObject.ValueOperation operation) + 0xf3 bytes
System.Windows.dll!System.Windows.DependencyObject.RefreshExpression(System.Windows.DependencyProperty dp) + 0x47 bytes
System.Windows.dll!System.Windows.Data.BindingExpression.SendDataToTarget() + 0xff bytes
System.Windows.dll!System.Windows.Data.BindingExpression.SourceAcquired() + 0x5f bytes
System.Windows.dll!System.Windows.Data.Binding.EnsureBreakPoint(System.Windows.Data.Debugging.BindingDebugState debugState, System.Action callback, bool canDelay) + 0x47 bytes
System.Windows.dll!System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(object sender, System.Windows.DataContextChangedEventArgs e) + 0xa4 bytes
System.Windows.dll!System.Windows.Data.BindingExpression.DataContextChanged(object sender, System.Windows.DataContextChangedEventArgs e) + 0xc bytes
System.Windows.dll!System.Windows.FrameworkElement.OnDataContextChanged(System.Windows.DataContextChangedEventArgs e) + 0x1e bytes
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e) + 0x26 bytes
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e) + 0xcb bytes
System.Windows.dll!System.Windows.FrameworkElement.OnTreeParentUpdated(System.Windows.DependencyObject newParent, bool bIsNewParentAlive) + 0x3d bytes
System.Windows.dll!System.Windows.DependencyObject.UpdateTreeParent(MS.Internal.IManagedPeer oldParent, MS.Internal.IManagedPeer newParent, bool bIsNewParentAlive, bool keepReferenceToParent) + 0x4a bytes
System.Windows.dll!MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(System.IntPtr oldParentElement, System.IntPtr parentElement, System.IntPtr childElement, byte bIsParentAlive, byte bKeepReferenceToParent, bool canCreateParent) + 0xf8 bytes
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x62 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0x9e bytes
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x62 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0x9e bytes
[Appdomain Transition]
[管理到本机转换]
System.Windows.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase obj,System.Windows.dependencProperty属性,字符串s)+0x6f字节
System.Windows.dll!MS.Internal.XcpImports.SetValue(MS.Internal.IManagedPeerBase doh,System.Windows.dependencProperty属性,对象obj)+0x2ce字节
System.Windows.dll!System.Windows.DependencyObject.SetObjectValueToCore(System.Windows.DependencyProperty dp,对象值)+0xd6字节
System.Windows.dll!System.Windows.DependencyObject.SetEffectiveValue(System.Windows.DependencyProperty属性,参考System.Windows.EffectiveValueEntry newEntry,object newValue)+0x35字节
System.Windows.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty属性,System.Windows.EffectiveValueEntry oldEntry,ref System.Windows.EffectiveValueEntry newEntry,System.Windows.DependencyObject.ValueOperation操作)+0xe6字节
System.Windows.dll!System.Windows.DependencyObject.SetValueInternal(System.Windows.DependencyProperty dp,对象值,bool ALLOREADONLYSET,bool isBindingInStyleSetter)+0x248字节
System.Windows.dll!System.Windows.Controls.TextBox.Text.set(字符串值)+0x33字节
Telerik.Windows.Controls.Input!Telerik.Windows.Controls.RadNumericUpDown.UpdateText()+0xa5字节
Telerik.Windows.Controls.Input!Telerik.Windows.Controls.RadNumericUpDown.OnValueChanged(Telerik.Windows.Controls.RadRangeBaseValueChangedEventArgs e)+0x1f5字节
Telerik.Windows.Controls!Telerik.Windows.Controls.RadRangeBase.OnValueChanged(System.Windows.DependencyObject d,System.Windows.DependencyPropertyChangedEventArgs e)+0x105字节
Telerik.Windows.Controls!Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged(System.Windows.DependencyObject d,System.Windows.DependencyPropertyChangedEventArgs e)+0x58b字节
System.Windows.dll!System.Windows.DependencyObject.RaisePropertyChangeNotifications(System.Windows.DependencyProperty dp、object oldValue、object newValue)+0x53字节
System.Windows.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty属性,System.Windows.EffectiveValueEntry oldEntry,ref System.Windows.EffectiveValueEntry newEntry,System.Windows.DependencyObject.ValueOperation操作)+0xf3字节
System.Windows.dll!System.Windows.DependencyObject.RefreshExpression(System.Windows.DependencyProperty dp)+0x47字节
System.Windows.dll!System.Windows.Data.BindingExpression.SendDataToTarget()+0xff字节
System.Windows.dll!System.Windows.Data.BindingExpression.SourceAcquired()+0x5f字节
System.Windows.dll!System.Windows.Data.Binding.EnsureBreakPoint(System.Windows.Data.Debugging.BindingDebugState debugState,System.Action回调,布尔坎德拉)+0x47字节
System.Windows.dll!System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(对象发送方,System.Windows.DataContextChangedEventArgs e)+0xa4字节
System.Windows.dll!System.Windows.Data.BindingExpression.DataContextChanged(对象发送方,System.Windows.DataContextChangedEventArgs e)+0xc字节
System.Windows.dll!System.Windows.FrameworkElement.OnDataContextChanged(System.Windows.DataContextChangedEventArgs e)+0x1e字节
System.Windows.dll!System.Windows.FrameworkElement.OnAncestorDataContextChanged(System.Windows.DataContextChangedEventArgs e)+0x26字节
System.Windows.dll!System.Windows.FrameworkElement.NotifyDataContextChanged(System.Windows.DataContextChangedEventArgs e)+0xcb字节
System.Windows.dll!System.Windows.FrameworkElement.OnTreeParentUpdated(System.Windows.DependencyObject newParent,bool bIsNewParentAlive)+0x3d字节
System.Windows.dll!System.Windows.DependencyObject.UpdateTreeParent(MS.Internal.IManagedPeer oldParent、MS.Internal.IManagedPeer newParent、bool bIsNewParentAlive、bool keepReferenceToParent)+0x4a字节
System.Windows.dll!MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(System.IntPtr oldParentElement、System.IntPtr parentElement、System.IntPtr childElement、byte bIsParentAlive、byte bKeepReferenceToParent、bool canCreateParent)+0xf8字节
[管理到本机转换]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement元素,System.Windows.Size可用大小)+0x62字节
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize)+0x18字节
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget、float inWidth、float inHeight、out float outWidth、out float outHeight)+0x9e字节
[管理到本机转换]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement元素,System.Windows.Size可用大小)+0x62字节
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize)+0x18字节
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget、float inWidth、float inHeight、out float outWidth、out float outHeight)+0x9e字节
[应用域转换]
首先,这是一行代码的大量强制转换。代码中的每种类型强制转换都意味着您知道更多
DefinitionDetailForm.SetNumericSpinnerMinValue(0);
static class FrameworkElementExtensions {
public T FindName<T>(this FrameworkElement parent, String name) {
var child = parent.FindName(name);
if (child == null)
throw new ArgumentException(
String.Format("No element named '{0}' exists.", name);
var typedChild = child as T;
if (typedChild == null)
throw new ArgumentException(
String.Format("Named element '{0}' has wrong type.", name);
return typedChild;
}
}
dataField.FindName<RadNumericUpDown>("DefinitionScoringPoints").Minimum = 0;