Error HRESULT E_FAIL has been returned from a call to a COM component.

1 posts, 0 answers
  1. Maruti
    Maruti avatar
    2 posts
    Member since:
    Oct 2011

    Posted 10 Oct 2011 Link to this post

    We have a RadMenuItem in my SL application, i am trying to remove an item from the RadMenuItem but i get this exception -

    {System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.Collection_RemoveAt[T](PresentationFrameworkCollection`1 collection, UInt32 index)
       at System.Windows.PresentationFrameworkCollection`1.RemoveAtImpl(Int32 index)
       at System.Windows.Controls.ItemCollection.RemoveAtImpl(Int32 index)
       at System.Windows.PresentationFrameworkCollection`1.RemoveAt(Int32 index)
       at Telerik.Windows.Controls.CollectionExtensions.RemoveAll[T](IList`1 collection)
       at NEMS.MainPage.Instance_GetTemplateMenuCompleted(Object sender, EventArgs`1 e)}

    As I am trying to remove all the submenus from existing RadMenuItem named - "template"
    When code reaches on the line - objRadMenuMainMenuMRUConnections.Items.RemoveAll(); , exception occurs.

    Telerik.Windows.Controls.RadMenuItem objRadMenuMainMenuMRUConnections = (Telerik.Windows.Controls.RadMenuItem)this.FindName("template");             
                    var distinctType = e.Value.Select(i => i.type_mid).Distinct();
                    for (int intConn = 0; intConn < distinctType.Count(); intConn++)
                        var typename1 = from n in e.Value where n.type_mid == distinctType.ElementAt(intConn) select n;
                        RadMenuItem objConnPart = new RadMenuItem();
                        objConnPart.Header = typename1.ElementAt(0).type_name.ToString();
                        objConnPart.Name = "typeNameMenu" + objConnPart.Header;                
                        objRadMenuMainMenuMRUConnections.Items.Insert(objRadMenuMainMenuMRUConnections.Items.Count, objConnPart);
                        RadMenuItem objMainMenu = (RadMenuItem)objConnPart;
                        for (int submenu = 0; submenu < typename1.Count(); submenu++)
                            RadMenuItem objSubMenu = new RadMenuItem();
                            objSubMenu.Header = typename1.ElementAt(submenu).template_name.ToString();
                            objSubMenu.Name = typename1.ElementAt(submenu).template_pid.ToString();
                            objSubMenu.Click += new RadRoutedEventHandler(objSubMenu_Click);
                            objMainMenu.Items.Insert(objMainMenu.Items.Count, objSubMenu);
Back to Top