Value cannot be null exception

Shell for WPF Forum

Posted 2 years ago by rex hui
Version: 19.1.2

I am getting the following exception when in my code, I called on my ShellObjectBase derived class when the column header is tapped.

RaiseChangedEvent(new ShellObjectChangedEventArgs(ShellObjectChangeKind.SortRequested, null));

Message=Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at ActiproSoftware.Windows.Controls.Shell.ShellObjectItemAdapter.SortChildren(TreeListBox ownerControl, ShellObjectViewModel parentViewModel, Boolean isReversingSortDirection)
at ActiproSoftware.Windows.Controls.Shell.ShellListView.OnViewModelModelChanged(Object sender, ShellObjectChangedEventArgs e)
at ActiproSoftware.Windows.Controls.Shell.ShellObjectViewModel.#N6j(Object #xhb, ShellObjectChangedEventArgs #yhb)
at ActiproSoftware.Windows.Controls.Shell.ShellObjectViewModel.#L6j(Object #xhb, ShellObjectChangedEventArgs #yhb)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at ActiproSoftware.Shell.ShellObjectBase.RaiseChangedEvent(ShellObjectChangedEventArgs e)

It is the key being null in the call to Dictionary`2.Insert. What is the key there and any idea why it is null?


Comments (2)

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA


The ShellObjectItemAdapter.SortChildren logic there is building a dictionary that maps the ShellObjectViewModel's Model value (the key) back to the ShellObjectViewModel instance.  It does this since the core sort logic has to be done on the model, but we need to then update the view-model collection to map the same order.  My guess is that your ShellObjectViewModel.Model property is null in that case somehow?

If you can't sort it out, please make a new simple sample project that shows it happening and send that to our support address, referencing this thread.  Exclude the bin/obj folders from the .zip you send so it doesn't get spam blocked.  Then we can debug with that and see what's going on.  Thanks!

Actipro Software Support

Posted 2 years ago by rex hui

I have figured out the cause of it.

Thank you!

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.