AnsweredAssumed Answered

Layout Crashing when using Configuration

Question asked by mjk5000 on Aug 22, 2018
Latest reply on Aug 22, 2018 by mjk5000

I have a custom application in which i remove all tools and tabs except for my tools located in my config.daml using this code in the ConfigurationManager.  All of my tools are used on the Map Tab.

protected override void OnUpdateDatabase(XDocument database)
        {

            var nsp = database.Root.Name.Namespace;
           
            // select all elements that are tabs
            var tabElements = from seg in database.Root.Descendants(nsp + "tab") select seg;
            // collect all elements that need to be removed
            var elements = new HashSet<XElement>();
            foreach (var tabElement in tabElements)
            {
                // skip root and backstage elements
                if (tabElement.Parent == null || tabElement.Parent.Name.LocalName.StartsWith("backstage"))
                    continue;

                var id = tabElement.Attribute("id");
                if (id == null || id.Value.StartsWith("MYIDS"))
                {
                    continue;//Skip our tabs
                }
               
                elements.Add(tabElement);
            }
            // remove the elements
            foreach (var element in elements)
            {
                element.Remove();
            }
        }

 

 

I think this might be an easy one, but I need to figure out why my application crashes when I load a layout from the code behind.  This opens a layout tab.  But when I click on one layout element (Text Element).  The config application crashes with the following errors.  My guess is this must have something to do with, when clicking on the Text Element in the layout tab, no menu exists for that Text Element?  I think I need to add back in the layout menus and Tabs.  But I really want my uses to only be able to use tools that I show in my configuration.

 

System.InvalidOperationException
  HResult=0x80131509
  Message=Sequence contains no matching element
  Source=System.Core
  StackTrace:
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at ArcGIS.Desktop.Framework.TabManager.UpdateTabGroupCaption(String id, String newCaption)
   at ArcGIS.Desktop.Layouts.Element.ActivateSelectedElementTab()
   at ArcGIS.Desktop.Layouts.Layout.<>c__DisplayClass171_0.<UpdateGUISelectionAsync>b__0()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at main(String[] args)

Outcomes