Where do I start troubleshooting this?

Where do I start troubleshooting this?

Old forum URL: forums.lhotka.net/forums/t/6419.aspx

albruan posted on Friday, February 13, 2009

I'm working with Cslalight.  My project currently consists of three XAML pages ... App.xaml, Page.xaml and MemberEditor.xaml.  I have a pushbutton in the Page.xaml to invoke a GetMember method in my class and display the result in the MemberEditor.xaml; GetMember returns a row of data from my database so that part is apparently working correctly.  However, I'm getting the following error and nothing is being displayed in the MemberEditor.xaml.

Element is already the child of another element.
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
   at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
   at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
   at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
   at System.Windows.PresentationFrameworkCollection`1.Add(T value)
   at eMediaSwap.Page.ShowControl(UserControl control)
   at eMediaSwap.Page.<>c__DisplayClass1.<Button1_Click>b__0(Object o1, EventArgs e1)
   at eMediaSwap.MemberEditor.OnDataLoaded()
   at eMediaSwap.MemberEditor.CslaDataProvider_DataChanged(Object sender, EventArgs e)
   at Csla.Silverlight.CslaDataProvider.OnDataChanged()
   at Csla.Silverlight.CslaDataProvider.set_Error(Exception value)
   at Csla.Silverlight.CslaDataProvider.QueryCompleted(Object sender, EventArgs e)
   at Csla.DataPortal`1.OnFetchCompleted(DataPortalResult`1 e)
   at Csla.DataPortal`1.proxy_FetchCompleted(Object sender, DataPortalResult`1 e)
   at Csla.DataPortalClient.SynchronizedWcfProxy`1.OnCompleted(Object sender, DataPortalResult`1 e, EventHandler`1 method)
   at Csla.DataPortalClient.SynchronizedWcfProxy`1.OnFetchCompleted(Object sender, DataPortalResult`1 e)
   at Csla.DataPortalClient.SynchronizedWcfProxy`1.<.ctor>b__2(Object o, DataPortalResult`1 e)
   at Csla.DataPortalClient.WcfProxy`1.OnFetchCompleted(DataPortalResult`1 e)
   at Csla.DataPortalClient.WcfProxy`1.proxy_FetchCompleted(Object sender, FetchCompletedEventArgs e)

How do I go about troubleshooting this and correcting the problem?

RockfordLhotka replied on Friday, February 13, 2009

Looks like you have some code triggered by the DataChanged event that is manipulating the XAML in an illegal manner.

Just reading the stack trace from bottom to top shows that your OnDataLoaded() method is invoked, and it apparently does something bad - perhaps in the ShowControl() method?

Copyright (c) Marimer LLC