views:

219

answers:

1

This is a wierd one and at this point I am thinking that it may have something to do with my machines configuration.

Basically I have created a pretty standard implementation of INotifyDataErrorInfo and in certain circumstances, when raising the ErrorsChanged event I get an ArgumentOutOfRangeException. This exception doesn't contain much info; it gives me ArgumentOutOfRangeException crossed a native/managed boundary plus the standard ArgumentOutOfRangeException description regarding non-negative indexes and collection sizes. The InnerException is null. The stack trace is as follows:

at System.ThrowHelper
        .ThrowArgumentOutOfRangeException(ExceptionArgument argument,
                                           ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Collections.ObjectModel.Collection`1.get_Item(Int32 index)
at System.Collections.ObjectModel.ReadOnlyCollection`1.get_Item(Int32 index)

The reason I mention my machine configuration is because I have tried a couple of solutions posted to blogs (e.g. here and here) and get the same problem (i.e. not my code, another implementation of INotifyDataErrorInfo) and there is no mention in the comments of any others getting the problem I do. Googling turns up a couple of random hits that don't help.

The state required is as follows:

  1. I have entered a value in to the control such that a validation error is triggered. (This works fine, the error text is displayed in the UI as expected).
  2. I then enter a new value in to the control such that validation will succeed and errors are removed from the error collection (HasErrors returns false).
  3. ErrorsChanged is being raised to reflect this change to successful validation with no errors, and the exception occurs.

UPDATE: I can also reproduce if I move focus away from a TextBox displaying a validation error.

I'm kind of wondering if I've missed a service pack/update or something because from what I'm seeing it looks as though theres a pretty elementary error in the framework code and at the same time its not happening for others.

UPDATE: I am using the final RTM build of Silverlight 4. NOT an RC or Beta.

UPDATE: I get the same result with the official MS sample provided with this whitepaper.

UPDATE: I have now tested my code and the mentioned samples on another machine and it works fine. I would still really like to resolve this as its a little unsettling that it isn't working on my regular machine (which I have not had any trouble with up until now). Any suggestions as to how I could track down what is causing this would be appreciated. I have re-installed Silverlight (Runtime, SDK, Toolkit) on the problem machine and this has not resolved the issue.

UPDATE: Here is the call stack of the framework code where the exception is occurring obtained by enabling source server support with MS symbol server:

mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource) + 0x40 bytes 
  mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException() + 0x10 bytes 
  mscorlib.dll!System.Collections.Generic.List<System.Windows.Controls.ValidationError>.this[int].get(int index = 0) + 0x13 bytes 
  mscorlib.dll!System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationError>.this[int].get(int index) + 0x2e bytes 
  mscorlib.dll!System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Controls.ValidationError>.this[int].get(int index) + 0x2e bytes 
  [Native to Managed Transition] 
  [Managed to Native Transition] 
  System.Windows.dll!System.Windows.IndexerListener.Value.get() + 0xc3 bytes 
  System.Windows.dll!System.Windows.IndexerPathStep.Value.get() + 0x17 bytes 
  System.Windows.dll!System.Windows.PropertyPathListener.RaisePropertyPathStepChanged(System.Windows.PropertyPathStep source = {System.Windows.IndexerPathStep}) + 0x17 bytes 
  System.Windows.dll!System.Windows.IndexerPathStep.RaisePropertyPathStepChanged(System.Windows.PropertyListener source) + 0xe bytes 
  System.Windows.dll!System.Windows.IndexerListener.SourcePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args) + 0xea bytes 
  System.Windows.dll!System.Windows.Data.WeakPropertyChangedListener.PropertyChangedCallback(object sender, System.ComponentModel.PropertyChangedEventArgs args) + 0x3d bytes 
  System.Windows.dll!System.Collections.ObjectModel.ReadOnlyObservableCollection<System.__Canon>.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args) + 0x17 bytes 
  System.Windows.dll!System.Collections.ObjectModel.ReadOnlyObservableCollection<System.__Canon>.HandlePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + 0xe bytes 
  System.Windows.dll!System.Collections.ObjectModel.ObservableCollection<System.Windows.Controls.ValidationError>.OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e) + 0x37 bytes 
  System.Windows.dll!System.Collections.ObjectModel.ObservableCollection<System.Windows.Controls.ValidationError>.RemoveItem(int index = 0) + 0x79 bytes 
  mscorlib.dll!System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationError>.Remove(System.Windows.Controls.ValidationError item) + 0x75 bytes 
  System.Windows.dll!System.Windows.Controls.Validation.RemoveValidationError(System.Windows.FrameworkElement fe = {System.Windows.Controls.TextBox}, System.Windows.Controls.ValidationError error) + 0x40 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.RemoveErrorFromTarget(System.Windows.Controls.ValidationError error) + 0x48 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.NotifyOldDataErrorInfos(System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationError> validationErrors) + 0x73 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.NotifyOldDataErrorInfos(bool isNotifyChildDataErrorInfo) + 0x25 bytes 
  System.Windows.dll!System.Windows.Data.BindingExpression.NotifyDataErrorInfo_ErrorsChanged(object sender, System.ComponentModel.DataErrorsChangedEventArgs e) + 0xad bytes 

UPDATE: The application runs fine (on the problem machine) without a debugger attached, works as expected and no unhandled exception scripts are invoked (This kinda had me stumped, could it be VS related?). I had a quick search on google to see if I could find any Silverlight plugin log file which may shed some light here with no luck, is there such a log?

A: 

I was able to fix this problem by removing the Silverlight application links from the web project and re-adding them.

Hope this helps.

Chooksii
unfortunately that didn't help, thanks anyway.
Simon Fox
Sorry to hear that. The strange thing is that I didn’t check in the changes, instead experimented by undoing the pending changes on the web project and rebuilding with the original files, to my surprise the problem did not reappear. I also unchecked (then rechecked) the Debug option in the web project and same with the RIA links to the projects in the process of resolving. Each time I did a Rebuild of the entire solution. Its bizarre as I’m only finding this error on machines with new installs.
Chooksii