Value cannot be null exception

Shell for WPF Forum

The latest build of this product (v22.1.2) was released 3 months ago, which was before this thread was created.
Posted 2 months 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 months 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 months ago by rex hui
Avatar

I have figured out the cause of it.

Thank you!

Add Comment

Please log in to a validated account to post comments.