_viewItemManager.FQID.ObjectIDString beyond bounds of ViewAndLayoutItem.GetChildren

We are using code copied from the SCToolbarPlugin sample to handle button presses from a Toolbar button to determine which ViewItem instance should respond to the button press.

The sample code does this by fetching the list of children using WindowInformation.ViewAndLayoutItem.GetChildren(), and indexing the returned list with int.Parse(_viewItemManager.FQID.ObjectIdString)

We’re finding that immediately after our plugin has been added to a view, the ObjectIdString is beyond the bounds of the returned list, throwing an ArgumentOutOfRangeException. Empirically, it seems to be equal to ViewItemLayout.GetChildren().Count, exactly one greater than the last item in the list.

This only happens on shared view groups, not private ones. The SCToolbarPlugin sample does not seem affected. Have reproduced in SC 2021R2 and 2022R2.

Restarting SmartClient always fixes this, and the button event handler finds the correct ViewItem instance.

What might cause our plugin to get an incorrect value from _viewItemManager.FQID.ObjectIdString?

I believe the ObjectIdString is not valid for all Items (the documentation mentions PTZ presets) and your observation seems to indicate this too. You can however always use Guid VideoOS.Platform.FQID.ObjectId

Ref. https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_f_q_i_d.html&tree=tree_search.html?search=fqid