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)
Reader Comments