2012-04-27 15 views
0

これまで多くのこのようなトピックは、この例外が1つの特定の場所(時間の5%)や他の場所で発生するという問題があります。保護されたメモリを読み書きしようとしました。これは、多くの場合、他のメモリが壊れていることを示しています

コードの最初の行は、まずこの

((DefinitionDetailForm.FindNameInContent("DataFieldDefinitionPoints") as DataField). 
         FindName("DefinitionScoringPoints") as RadNumericUpDown). 
         Minimum = 0; 

である私は、私は多分フィールドに参照を保持する必要があるが、これはどちらか助けていないと思いました。少なくとも最初のものについての考えを持つ

他の状況は、私はすべての詳細情報を与えることができないように、私も、コールスタックには何も得ることはありませんそのため、未定義の場所にある:(

誰でも?

編集:事は最初にその

 
[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] 

答えて

1

例外は、何かが管理されていないメモリを壊れていることを示します。破損は、例外がスローされる前にある時点で発生することが多く、問題のトラブルシューティングを困難にします。スピナーはまったく関与していないかもしれませんが、単にあなたのアプリケーションでもっと不吉な問題のメッセンジャーです。

Silverlightで管理されていないメモリを壊す1つの方法しか考えられません。それはSilverlight 5でP/Invokeを使用することです。コードのその部分を注意深く見てください。

質問のキャストは決して有害ではありません。最悪の場合、コントロールが見つからないか間違ってNullReferenceExceptionがトリガーされますが、アンマネージメモリが破損することはありません。その後

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; 

Telerik固有の呼び出しには、同様の拡張メソッドを実装する必要があります。

0

まあまず物事を壊しキャストの多くは共同のシングルラインのためだ

コールスタックde。コード内のすべての型キャストは、コードよりもはるかに多くを知っていることを意味しますが、これは悪いことです。また、Findメソッドが返す可能性もありますnull

フォームのNumeric Spinnerの最小値を設定しようとしている場合は、フォーム内で行うことをお勧めしますの。

DefinitionDetailForm.SetNumericSpinnerMinValue(0); 

そしてSetNumericSpinnerMinValueは、適切なヌルチェックとスピナーのためのMIN値を設定するためのロジックを持つことができます。

例外が発生すると思われるコードの周りにtry/catchブロックを使用してください。

もう一度 - それらのキャストを取り除く!

+0

ありがとうございました...試してみましょう...キャストに関しては、最後のチームが書いたようにこのコードを手に入れました。このキャストは何百万もあります。私たちの目標は、このバグをシステムから取り除いた後、すべてをHTML 5に変換することです...もう一度感謝します –

関連する問題