handling OnPropertyChanged() with empty string argument

Dec 22, 2011 at 12:20 AM

Hi,

I have recently begun 'playing' with Catel and  have been using it to replace my existing non MVVM UI framework.

I also work with CSLA.NET & have recently found an issue, which I believe lies in Catel.

At times CSLA can call OnPropertyChanged(String.Empty) and this results in Catel throwing a System.ArgumentException ('Argument 'name' cannot be null...').

I have posted on the CSLA.Net forume & been told that the relevant Microsoft documentation states:

"The PropertyChanged event can indicate all properties on the object have chnaged by using either Nothing or String.Empty as the property name in the PropertyChangedEventArgs."

Any opinions?



Dec 22, 2011 at 7:36 AM

Thanks for the detailed information. I am assuming that you are using CSLA as the model object? It is true that you can pass string.Empty or Null (Nothing) to RaisePropertyChange. Do you have the callstack or the line where the exception occurs? The ArgumentException should be easy to locate.

Thanks in advance!

Dec 22, 2011 at 7:20 PM

Hi, thanks for your reply. Yes I am using CSLA for the model layer.

The complete exception details that I get from VS are listed below.

System.ArgumentException was unhandled
  Message=Argument 'name' cannot be null or whitespace
Parameter name: name
  Source=Catel.Core
  ParamName=name
  StackTrace:
       at Catel.Argument.IsNotNullOrWhitespace(String paramName, String paramValue)
       at Catel.Data.PropertyDataManager.IsPropertyRegistered(Type type, String name)
       at Catel.Data.DataObjectBase.IsPropertyRegistered(Type type, String name)
       at Catel.Data.DataObjectBase.IsPropertyRegistered(String name)
       at Catel.Data.DataObjectBase.IsDataObjectBaseProperty(String name)
       at Catel.Data.DataObjectBase.RaisePropertyChanged(Object sender, PropertyChangedEventArgs e, Boolean setDirtyAndAllowAutomaticValidation, Boolean isRefreshCallOnly)
       at Catel.Data.DataObjectBase.OnObjectPropertyChanged(Object sender, PropertyChangedEventArgs e)
       at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
       at Csla.Core.BindableBase.OnPropertyChanged(String propertyName) in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\Core\BindableBase.cs:line 114
       at Csla.Core.BindableBase.OnUnknownPropertyChanged() in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\Core\BindableBase.cs:line 97
       at Csla.Core.BusinessBase.MarkDirty(Boolean suppressEvent) in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\Core\BusinessBase.cs:line 311
       at Csla.Core.BusinessBase.MarkDirty() in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\Core\BusinessBase.cs:line 296
       at Csla.Core.BusinessBase.MarkDeleted() in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\Core\BusinessBase.cs:line 274
       at Csla.Core.BusinessBase.DeleteChild() in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\Core\BusinessBase.cs:line 909
       at Csla.Core.BusinessBase.Csla.Core.IEditableBusinessObject.DeleteChild() in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\Core\BusinessBase.cs:line 1462
       at Csla.BusinessListBase`2.DeleteChild(C child) in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\BusinessListBase.cs:line 127
       at Csla.BusinessListBase`2.RemoveItem(Int32 index) in E:\_development\Csla\CslaSource-4.2.0-111004\Source\Csla\BusinessListBase.cs:line 356
       at System.Collections.ObjectModel.Collection`1.Remove(T item)
       at Catel_001.ViewModels.ChildListMgr`1.RemoveItem(T item) in E:\_development\__App Templates\csla_app\__latest\Catel_001\ViewModels\UserEditViewModel.cs:line 121
       at Catel_001.ViewModels.ChildListMgr`1.OnRemoveExecute() in E:\_development\__App Templates\csla_app\__latest\Catel_001\ViewModels\UserEditViewModel.cs:line 99
       at Catel.MVVM.Command`2.Execute(TExecuteParameter parameter)
       at Catel.MVVM.Command`2.Execute(Object parameter)
       at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
       at System.Windows.Controls.Primitives.ButtonBase.OnClick()
       at System.Windows.Controls.Button.OnClick()
       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
       at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at Catel_001.App.Main() in E:\_development\__App Templates\csla_app\__latest\Catel_001\obj\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Dec 23, 2011 at 9:48 AM

Will fix this asap.

Dec 23, 2011 at 9:57 AM

Done, you can get the latest beta via nuget. The version is (don't get scared of the version number :)):

Update-Package Catel.Core –IncludePrerelease -version 2.4.1112231055-beta

Dec 26, 2011 at 9:55 PM

Hi, your fix works perfectly.

thanks for your quick response.