I've read all the threads on this topic and tried the various things mentioned, but haven't gotten anywhere. This is almost a FAQ, but it seems like there are lots of things that could cause this.
I'm dynamically adding usercontrols to a canvas using Children.Add. That works, and I have verified them both visually and by walking the tree to see they are there and named as expected.
I'm also adding storyboard that work on those usercontrols. I add these via canvas.Resources.Add().
An example of the xaml I use to add the storyboard (pasted from the output window) is here:
I have tried both with and without the namespaces. I have set the target name via code as you see above and also directly in the xaml. I have verified that my storyboards are all named uniquely. In every instance, I get a catastrophic failure on Begin().
If I leave out the Begin(), my tree is correct, but obviously it doesn't do what I want :)
Message "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
StackTrace " at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)\r\n at System.Windows.DependencyObject.MethodEx(String methodName, CValue[] cvData)\r\n at System.Windows.Media.Animation.Storyboard.Begin()\r\n at PeteBrown.SilverlightWallpaperViewer.ThumbnailPresenter.AnimateThumbnailsToPosition()\r\n
at PeteBrown.SilverlightWallpaperViewer.Page.Resize()\r\n at PeteBrown.SilverlightWallpaperViewer.Page.BrowserHost_Resize(Object sender, EventArgs e)\r\n at System.Windows.Interop.BrowserHost.FireResize(Object sender, EventArgs args)\r\n at MS.Internal.JoltHelper.FireEvent(IntPtr
unmanagedObj, String objectName, IntPtr unmanagedObjArgs, String objectNameArgs, String eventName)"
Any suggestions?
Pete
PS. FindByName<> just looks like this:
protected T FindByName<T>(string name)
where T : DependencyObject
{
return _rootElement.FindName(name)
as T;
}
Developer Community Program Manager - XAML, WPF, Silverlight, .NETMF/Gadgeteer
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
I did something very similar once and had no "Catastrophic Failure" when starting the Storyboard with the Begin() method.
I compared the XAML of your Storyboard to mine and found the following differences:
My Storyboard has no xml namespace definitions in its attribute list
This results in the Name attribute simply being "Name" and not "x:Name"
My Animation uses KeyFrames (DoubleAnimationUsingKeyFrames with SplineKeyFrames XAML child objects) - never mind
I set the Target of the Storyboard right in the XAML - never mind
So maybe you can try to adapt your storyboard to point 1 and 2 and see if that helps.
Another thing:
Looking at the StackTrace there is a DependencyObject in this scenario. Another guess would be that "thumbnail" has no accessible Canvas.Left property. In my Storyboard the target is a Rectangle and the TargetProperty is (UIElement.Opacity).
Another possibility...I've had catastrophic failures when two storyboards are running simultaneously and are trying to modify the same property of the same object.
the namespace and the x: go together. I have tried both with and without. If you don't use the xmlns definition, then you use regular Name. If you do use the def, then you use x:Name.
I know the thumbnail has canvas.left/top as I set those to 0 in an earlier bit of code.
Thanks also to Bill. I doubt that is the issue here, but I will double-check as you never know. :)
For grins, maybe I'll create a translation transform and try animating that instead of the attached left/top properties. I've animated those prorperties through xaml before, so if there is an issue here, it's just with doing it all via code.
Pete
Developer Community Program Manager - XAML, WPF, Silverlight, .NETMF/Gadgeteer
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
Thanks Mark. That will help with debugging. I hope to get back on to this problem tonight and post an update here.
Pete
Developer Community Program Manager - XAML, WPF, Silverlight, .NETMF/Gadgeteer
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
It may have to do with how many layer of objects you have and where you put the storyboard.
Is this what your hierarchy looks like?
Canvas {Root}
Canvas {Main Screen}
Canvas {sub section}
Canvas {Added control and the one you’re trying to animate}
Storyboard
Try moving the storyboard to the absolute root.
Canvas {Root}
Storyboard – Added here instead. Not sure what the target name would be, something long I expect.
Canvas {Main Screen}
Canvas {sub section}
Canvas {Added control and the one you’re trying to animate}
Developer Community Program Manager - XAML, WPF, Silverlight, .NETMF/Gadgeteer
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
I have no idea why you think I would structure my controls that way [;)]
If you take out the subsection, you're close about the structure:
Canvas {Page}
Canvas {Thumbnail Presenter; container for the usercontrols}
Storyboard
UserControl and its Canvas
So, in theory, the storyboard is where it needs to be. Moving it to the page would be a pain, and shouldn't be necessary (but we are using an alpha, so who knows)
From a previous post, it looks like it's something specific about animating the position of a usercontrol, as another poster used my code to animate some basic shapes and it worked. I didn't get a chance to play with this any more this weekend. Perhaps today.
"Catastrophic Failure: i'll melt ur cpu"
Thanks
Pete
Developer Community Program Manager - XAML, WPF, Silverlight, .NETMF/Gadgeteer
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
Psychlist1972
Contributor
6802 Points
1079 Posts
Microsoft
Moderator
Catastrophic Failure with Dynamically Loaded Storyboard
Oct 20, 2007 05:33 AM | LINK
I've read all the threads on this topic and tried the various things mentioned, but haven't gotten anywhere. This is almost a FAQ, but it seems like there are lots of things that could cause this.
I'm dynamically adding usercontrols to a canvas using Children.Add. That works, and I have verified them both visually and by walking the tree to see they are there and named as expected.
I'm also adding storyboard that work on those usercontrols. I add these via canvas.Resources.Add().
An example of the xaml I use to add the storyboard (pasted from the output window) is here:
<Storyboard xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="sb_t000000" >
<DoubleAnimation Storyboard.TargetProperty="(Canvas.Left)" To="0" Duration="0:0:0.25" />
<DoubleAnimation Storyboard.TargetProperty="(Canvas.Top)" To="0" Duration="0:0:0.25" />
</Storyboard>
This is what the generating code looks like: xaml += "<Storyboard xmlns=\"http://schemas.microsoft.com/client/2007\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"" + storyboardName + "\" > "; //xaml += "<Storyboard Name=\"" + storyboardName + "\" > "; //xaml += "<Storyboard>"; xaml += " <DoubleAnimation Storyboard.TargetProperty=\"(Canvas.Left)\" To=\"" + newX + "\" Duration=\"0:0:0.25\" />";xaml +=
" <DoubleAnimation Storyboard.TargetProperty=\"(Canvas.Top)\" To=\"" + newY + "\" Duration=\"0:0:0.25\" />"; //xaml += " <DoubleAnimation Storyboard.TargetName=\"" + thumbnail.Name + "\" Storyboard.TargetProperty=\"(Canvas.Left)\" To =\"" + newX + "\" Duration=\"0:0:0.25\"/>"; //xaml += " <DoubleAnimation Storyboard.TargetName=\"" + thumbnail.Name + "\" Storyboard.TargetProperty=\"(Canvas.Top)\" To =\"" + newY + "\" Duration=\"0:0:0.25\"/>"; xaml += "</Storyboard>";System.Diagnostics.
Debug.WriteLine(xaml); Storyboard storyboard = (Storyboard)XamlReader.Load(xaml);storyboard.SetValue(
Storyboard.TargetNameProperty, thumbnail.Name); FindByName<Canvas>("parentCanvas").Resources.Add(storyboard); //this.Resources.Add(storyboard);storyboard.Begin();
I have tried both with and without the namespaces. I have set the target name via code as you see above and also directly in the xaml. I have verified that my storyboards are all named uniquely. In every instance, I get a catastrophic failure on Begin(). If I leave out the Begin(), my tree is correct, but obviously it doesn't do what I want :)
Message "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
StackTrace " at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)\r\n at System.Windows.DependencyObject.MethodEx(String methodName, CValue[] cvData)\r\n at System.Windows.Media.Animation.Storyboard.Begin()\r\n at PeteBrown.SilverlightWallpaperViewer.ThumbnailPresenter.AnimateThumbnailsToPosition()\r\n at PeteBrown.SilverlightWallpaperViewer.Page.Resize()\r\n at PeteBrown.SilverlightWallpaperViewer.Page.BrowserHost_Resize(Object sender, EventArgs e)\r\n at System.Windows.Interop.BrowserHost.FireResize(Object sender, EventArgs args)\r\n at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, String objectName, IntPtr unmanagedObjArgs, String objectNameArgs, String eventName)"
Any suggestions?
Pete
PS. FindByName<> just looks like this:
protected T FindByName<T>(string name) where T : DependencyObject{
return _rootElement.FindName(name) as T;
}
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
balla
Member
674 Points
200 Posts
Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 20, 2007 09:45 AM | LINK
Hello, I hope I can help you here.
I did something very similar once and had no "Catastrophic Failure" when starting the Storyboard with the Begin() method.
I compared the XAML of your Storyboard to mine and found the following differences:
So maybe you can try to adapt your storyboard to point 1 and 2 and see if that helps.
Another thing:
Looking at the StackTrace there is a DependencyObject in this scenario. Another guess would be that "thumbnail" has no accessible Canvas.Left property. In my Storyboard the target is a Rectangle and the TargetProperty is (UIElement.Opacity).
Post back if this helped.
Bill Reiss
Contributor
4973 Points
947 Posts
Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 20, 2007 11:53 AM | LINK
Another possibility...I've had catastrophic failures when two storyboards are running simultaneously and are trying to modify the same property of the same object.
Bill Reiss, Coauthor of Hello! Silverlight
My blog
Psychlist1972
Contributor
6802 Points
1079 Posts
Microsoft
Moderator
Re: Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 20, 2007 02:24 PM | LINK
Thanks Balla
the namespace and the x: go together. I have tried both with and without. If you don't use the xmlns definition, then you use regular Name. If you do use the def, then you use x:Name.
I know the thumbnail has canvas.left/top as I set those to 0 in an earlier bit of code.
Thanks also to Bill. I doubt that is the issue here, but I will double-check as you never know. :)
For grins, maybe I'll create a translation transform and try animating that instead of the attached left/top properties. I've animated those prorperties through xaml before, so if there is an issue here, it's just with doing it all via code.
Pete
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
MarkTap
Participant
1538 Points
281 Posts
Re: Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 20, 2007 04:36 PM | LINK
I can't be much help, here's just a reality check: I used your code to animate a rectangle and an ellipse and it worked great.
Psychlist1972
Contributor
6802 Points
1079 Posts
Microsoft
Moderator
Re: Re: Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 21, 2007 04:20 PM | LINK
Thanks Mark. That will help with debugging. I hope to get back on to this problem tonight and post an update here.
Pete
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
ssuing8825
Member
114 Points
51 Posts
Re: Re: Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 22, 2007 01:18 PM | LINK
Here is a guess.
It may have to do with how many layer of objects you have and where you put the storyboard.
Is this what your hierarchy looks like?
Canvas {Root}
Canvas {Main Screen}
Canvas {sub section}
Canvas {Added control and the one you’re trying to animate}
Storyboard
Try moving the storyboard to the absolute root.
Canvas {Root}
Storyboard – Added here instead. Not sure what the target name would be, something long I expect.
Canvas {Main Screen}
Canvas {sub section}
Canvas {Added control and the one you’re trying to animate}
jasonxz
Participant
1787 Points
557 Posts
Re: Re: Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 22, 2007 01:56 PM | LINK
Hey Pete,
If ssuing8825's post doesn't fix it, could you publish the final Storyboard XAML string so we can look at it?
Psychlist1972
Contributor
6802 Points
1079 Posts
Microsoft
Moderator
Re: Re: Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 22, 2007 03:23 PM | LINK
Hi Jason.
The storyboard xaml is in the first post, thanks.
Pete
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.
Psychlist1972
Contributor
6802 Points
1079 Posts
Microsoft
Moderator
Re: Re: Re: Catastrophic Failure with Dynamically Loaded Storyboard
Oct 22, 2007 03:30 PM | LINK
Hey Steve
I have no idea why you think I would structure my controls that way [;)]
If you take out the subsection, you're close about the structure:
Canvas {Page}
Canvas {Thumbnail Presenter; container for the usercontrols}
Storyboard
UserControl and its Canvas
So, in theory, the storyboard is where it needs to be. Moving it to the page would be a pain, and shouldn't be necessary (but we are using an alpha, so who knows)
From a previous post, it looks like it's something specific about animating the position of a usercontrol, as another poster used my code to animate some basic shapes and it worked. I didn't get a chance to play with this any more this weekend. Perhaps today.
"Catastrophic Failure: i'll melt ur cpu"
Thanks
Pete
10rem.net - Pete Brown's site and blog | twitter: @pete_brown
I work for the Developer Guidance group in Microsoft. Opinions are my own.