Hi,
In my project I have an employee and for this employee regimes can be added. If I add a regime and save the employee everything works fine. If I then add another regime I get a NullReferenceException(Object reference not set to an instance of an object) in EmployeeRegimeList in
protected override void InsertItem(int index, EmployeeRegime item)
{base.InsertItem(index, item);}
with base being BusinessListBase<x,y>
Any idea what is going wrong? Is this a known bug?
at Csla.LinqBindingList`1.ItemShouldBeInList(T item)
at Csla.LinqBindingList`1.SourceChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.InsertItem(Int32 index, T item)
at Csla.BusinessListBase`2.InsertItem(Int32 index, C item)
at Rls.CapacityPlanning.Entities.EmployeeRegimeList.InsertItem(Int32 index, EmployeeRegime item) in C:\Real\Projects\TrunkCab\CapPlanV2\Source\Entities\Rls.CapacityPlanning.Entities\EmployeeRegimeList.cs:line 28
at System.Collections.ObjectModel.Collection`1.Add(T item)
at Rls.CapacityPlanning.Entities.Employee.AddRegime(DateTime fromDate, Nullable`1 toDate, Int32 regimeID) in C:\Real\Projects\TrunkCab\CapPlanV2\Source\Entities\Rls.CapacityPlanning.Entities\Employee.cs:line 299
at Rls.CapacityPlanning.Planning.Views.EmployeeDetail.EmployeeDetailViewPresenter.AddRegime(Object sender, EventArgs e) in C:\Real\Projects\TrunkCab\CapPlanV2\Source\Planning\Planning\Views\EmployeeDetail\EmployeeDetailViewPresenter.cs:line 475
at Microsoft.Practices.CompositeUI.Commands.Command.OnExecuteAction(Object sender, EventArgs e)
at Microsoft.Practices.CompositeUI.Commands.CommandAdapter.FireCommand()
at Microsoft.Practices.CompositeUI.Commands.EventCommandAdapter`1.InvokerEventHandler(Object sender, EventArgs e)
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(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
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(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(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, Int32 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, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
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.Threading.Dispatcher.Run()
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at SCSFContrib.CompositeUI.WPF.ApplicationShellApplication`2.Start()
at Microsoft.Practices.CompositeUI.CabApplication`1.Run()
at Rls.CapacityPlanning.Shell.Shell.Main() in C:\Real\Projects\TrunkCab\CapPlanV2\Source\Infrastructure\Shell\Shell.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly 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)
at System.Threading.ThreadHelper.ThreadStart()
Yes, it appears to be a bug. The fix should be to change ItemShouldBeInList() to this:
private bool ItemShouldBeInList(T item)
{
InnermostWhereFinder whereFinder = new InnermostWhereFinder();
MethodCallExpression whereExpression = whereFinder.GetInnermostWhere(_expression);
Expression<Func<T, bool>> whereBody = (Expression<Func<T, bool>>)((UnaryExpression)(whereExpression.Arguments[1])).Operand;var searchable = _list as Linq.IIndexSearchable<T>;
if (searchable == null)
return false;
else
return searchable.SearchByExpression(whereBody).Contains(item);
}
I've put this fix into svn for 3.5.1.
VB users should note that the code is a bit different there, but I've put an equivalent fix into svn in the VB edition as well for 3.5.1.
Copyright (c) Marimer LLC