Hi
Today we swiched from 14.1.9 to 14.2.5. BUT
we have some difficulties getting the SetDXContextMenu up and running. We have a n exception on it all the time.
C#public virtual void CreatePopup()
{
m_Popup = new PopupMenu { StaysOpen = true };
BarManager.SetBarManager(m_Popup, m_Manager);
m_Popup.Opening += OnPopupOpening;
m_Popup.Opened += PopupOpened;
m_Popup.Closed += PopupClosed;
RegisterCommands();
CreateContextMenu();
BarManager.SetDXContextMenu(m_Owner, m_Popup);
}
Can you see what we're doing wrong here?
Hi Alexander,
I have copied your code to a clean sample, but was unable to reproduce the issue using it. I feel that you create elements (for example, Bar*Item objects) with the same names in your methods (RegisterCommands, CreateContextMenu). Please check this. If you're unable to find the cause of the problem, can you send me the code of these methods?
Trying to find a small example, often not easy
Changing GlobalSkipUniquenessCheck fixes it for me. What does it do exactly? I decompiled core, but unfortunatly I cannot see the value of "object name".
Can you tell the developers to SHOW the name from now on in exceptions. It would save everybody a huge amount of time.
static AbstractPopupContext()
{
ElementRegistrator.GlobalSkipUniquenessCheck = true;
}
public void Add(IBarNameScopeSupport element)
{
if (this.IsValidName(element) && !this.Elements.ContainsValue(element))
{
object name = this.GetName(element);
if ((this.Unique && this.Elements.ContainsKey(name)) && !this.ActualSkipUniquenessCheck)
{
throw new InvalidOperationException("Element with the same name already exists in the scope");
}
this.Elements.Add(name, element);
this.RaiseChanged(element, ElementRegistratorChangeType.ElementAdded, name, name);
}
}
thanks
a
Hello Alexander,
I'm happy to hear that you've found the solution for your situation. Thank you for informing us of your results. If you provide us with your project, we can try to research it to find the cause of the issue and suggest a more suitable solution for your case. Please note that you can mark this ticket Private and nobody except my colleagues and I have access to it.
Setting the ElementRegistrator.GlobalSkipUniquenessCheck static property to True simply turns off the exception if there is a duplicated name conflict. Your suggestion about including the element's name into the exception's message makes sense and I've created a separate ticket with it: Show the name of the BarItem in the InvalidOperationException, which is caused by adding this item into the BarManager. Our developers will consider it in future and probably will provide the corresponding modifications.
Thanks,
Andrey