Value cannot be null exception

Shell for WPF Forum

Posted 2 years ago by rex hui
Version: 19.1.2
Avatar

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));

System.ArgumentNullException
HResult=0x80004003
Message=Value cannot be null.
Parameter name: key
Source=mscorlib
StackTrace:
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?

Thanks

Comments (2)

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

Hello,

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
Avatar

I have figured out the cause of it.

Thank you!

The latest build of this product (v24.1.1) 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.