« Debugging Expression Blend Design Time Errors | Main | ADO.NET Data Services - The server encountered an error »

Silverlight MeasureOverride Watch Your Size

I spent some time today tracking down a strange unhandled exception I was getting. The error basically said “Value was Out of Range”.   Of course telling me which value or what the value was not an option!  The worse part about the error was it was bypassing my unhandled exception handler and just crashing the Silverlight application. 

It turns out after digging around the MeasureOverride method was used to adjust the sizing and it was returning an available size that was just slightly (not even 1 over) over the original available size.  So if your getting this type of error, check the values your returning to make sure the are within your original available size that was passed in.

 

Exception stack trace:

   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
   at MyCodeXYZZZ.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)

Posted on Saturday, November 29, 2008 at 06:18PM by Registered CommenterDavid Yack | CommentsPost a Comment

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>