This is a mirror of official site: http://jasper-net.blogspot.com/

Silverlight: Why do I get 0x8000ffff when using WriteableBitmap on an Element

| Wednesday, October 20, 2010
I'm working on a WP7 library which helps analyze your VisualTree and to provide a visual aid, I take WriteableBitmap snaps of the elements. Unfortunately I (seemingly) randomly encounter the following exception:

A first chance exception of type 'System.Exception' occurred in System.Windows.dll

When digging into the exception you may find that the error is actually a HRESULT which is being bubbled up from the lower native layer:

E_UNEXPECTED (0x8000ffff)

What's going on?

You guessed it - this isn't random! In fact, this only happens on completely obscured (or off screen) elements which have never had a chance to render. In this case when you try to take a WriteableBitmap snap, instead of it forcing the control to render, it simply fails. This will hit you in the case of any element that has always been obscured. As soon as the element is unobscured it will be good to go (so you could do some VisualTree manipulation if you *really* needed to grab that shot).

Read more: Randomisation

Posted via email from .NET Info

0 comments: